当前位置: 首页>>代码示例>>C#>>正文


C# Repository.InsertOnSubmit方法代码示例

本文整理汇总了C#中Repository.InsertOnSubmit方法的典型用法代码示例。如果您正苦于以下问题:C# Repository.InsertOnSubmit方法的具体用法?C# Repository.InsertOnSubmit怎么用?C# Repository.InsertOnSubmit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Repository的用法示例。


在下文中一共展示了Repository.InsertOnSubmit方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CategoriesShouldBeReturnedNested

        public void CategoriesShouldBeReturnedNested()
        {
            using (new TransactionScope())
            {
                var connectionStringProvider = new ConnectionStringProvider("<my connection string>");
                var dataContextProvider = new DataContextProvider(connectionStringProvider);

                // first insert a new graph into the database
                var categoryRepository = new Repository<Category>(dataContextProvider);

                // use the object graph created by the mock category repository
                var root = MockRepositoryBuilder.CreateCategoryRepository().GetRootCategory();

                // add the root into the real database
                categoryRepository.InsertOnSubmit(root);

                categoryRepository.SubmitChanges();

                // try to get the root again (note we need the actual id because we don't want the real root,
                // which will have a different graph of categories, from the database)
                var rootFromDb = categoryRepository.GetById(root.CategoryId);

                MockRepositoryBuilder.AssertCategoryGraphIsCorrect(rootFromDb);
            }
        }
开发者ID:bertusmagnus,项目名称:Sutekishop,代码行数:25,代码来源:CategoryRepositoryTests.cs

示例2: CreateCollectionData

        public static void CreateCollectionData(int locationId, int userId)
        {
            CheckoutDataContextProvider dcp = CheckoutDataContextProvider.Instance;

            Repository<CollectionData> rep = new Repository<CollectionData>(dcp);

            CollectionData collectionData = new CollectionData();
            collectionData.LocationID = locationId;

            rep.InsertOnSubmit(collectionData);
            dcp.CommitChanges(userId);
        }
开发者ID:NGITechnology,项目名称:BeymenCheckout,代码行数:12,代码来源:CollectionDataBL.cs

示例3: SaveOrders

        public static List<string> SaveOrders(List<OrderDO> orders, int userId)
        {
            List<string> savedOrderCodes = new List<string>();
            using (TransactionScope tran = TransactionScopeFactory.CreateTransactionScope())
            {
                Repository<Order> rep = new Repository<Order>(CheckoutDataContextProvider.Instance);
                foreach (var orderDO in orders)
                {
                    string validationProblem = string.Empty;
                    bool isOrderValid = ValidateIncomingOrder(orderDO, ref validationProblem);
                    if (isOrderValid == false)
                    {
                        ElmahLogger.Warn(string.Format("{0} kaydedilemiyor. Valid değil : {1}", orderDO.Code, validationProblem));
                        continue;
                    }

                    Order existingOrder = rep.GetAll().FirstOrDefault(x => x.Code == orderDO.Code);
                    if (existingOrder != null)
                    {
                        ElmahLogger.Warn(string.Format("{0} sipariş zaten var. Atlanıyor", orderDO.Code));
                        savedOrderCodes.Add(existingOrder.Code);
                        continue;
                    }

                    Order orderToSave = MapOrderDOToOrder(orderDO);
                    List<OrderItem> orderItemListToSave = MapOrderItemDOListToOrderItem(orderDO.ItemList);

                    var defaultPackagingLocation = LocationBL.GetDefaultPackagingLocation(orderToSave.StoreID);

                    orderItemListToSave.ForEach(x =>
                    {
                        if (string.IsNullOrEmpty(x.ItemIdentifier) == false)
                        {
                            x.PackagingLocationID = defaultPackagingLocation.ID;
                        }

                        x.StatusCode = OrderItemStatus.LocationWaiting.ToString();
                        x.StatusCodeUpdateTime = DateTime.UtcNow;
                    });

                    orderToSave.OrderItems.AddRange(orderItemListToSave);

                    rep.InsertOnSubmit(orderToSave);
                    savedOrderCodes.Add(orderToSave.Code);
                }

                rep.DCP.CommitChanges(userId);
                tran.Complete();
            }
            return savedOrderCodes;
        }
开发者ID:NGITechnology,项目名称:BeymenCheckout,代码行数:51,代码来源:CheckoutBL.cs

示例4: Save

        public static int Save(ColorMappingDO colorMappingDO, int userID)
        {
            Repository<ColorMapping> repColor = new Repository<ColorMapping>(BeymenDataContextProvider.Instance);
            ColorMapping colorMapping;

            if (colorMappingDO.ID == 0)
            {
                colorMapping = new ColorMapping();
                ObjectMapper.MapObjects<ColorMappingDO, ColorMapping>(colorMappingDO, colorMapping);
                repColor.InsertOnSubmit(colorMapping);
            }
            else
            {
                colorMapping = repColor.GetAll().Where(x => x.ID == colorMappingDO.ID).SingleOrDefault();
                ObjectMapper.MapObjects<ColorMappingDO, ColorMapping>(colorMappingDO, colorMapping);
                repColor.UpdateByIdOnSubmit(colorMapping);
            }

            repColor.DCP.CommitChanges(userID);

            return colorMapping.ID;
        }
开发者ID:NGITechnology,项目名称:BeymenCheckout,代码行数:22,代码来源:ColorMappingBL.cs

示例5: Save

        public static void Save(Store_LocationDO model, int userID)
        {
            Repository<Store_Location> rep = new Repository<Store_Location>(CheckoutDataContextProvider.Instance);
            Store_Location dbObject;
         
            if (model.ID == 0)
            {
                dbObject = new Store_Location();
                Mapper.Map<Store_LocationDO, Store_Location>(model, dbObject);
                rep.InsertOnSubmit(dbObject);
            }
            else
            {
                dbObject = rep.GetAll().Where(x => x.ID == model.ID).SingleOrDefault();
                Mapper.Map<Store_LocationDO, Store_Location>(model, dbObject);
            }

            rep.DCP.CommitChanges(userID);
            
            Mapper.Map<Store_Location, Store_LocationDO>(dbObject, model);
                        
        }
开发者ID:NGITechnology,项目名称:BeymenCheckout,代码行数:22,代码来源:CollectionPackagingCenterBL.cs

示例6: Save

        public static void Save(UserLocationDO model, int userID)
        {
            Repository<UserLocation> rep = new Repository<UserLocation>(CheckoutDataContextProvider.Instance);
            UserLocation dbObject;
            if (rep.GetAll().Where(x => x.UserName == model.UserName && x.LocationID == model.LocationID).SingleOrDefault() != null)
            {
                throw new BusinessException("Bu kullanıcı için bu lokasyon tanımlanmış");
            }

            if (model.ID == 0)
            {
                dbObject = new UserLocation();
                Mapper.Map<UserLocationDO, UserLocation>(model, dbObject);
                rep.InsertOnSubmit(dbObject);
            }
            else
            {
                dbObject = rep.GetAll().Where(x => x.ID == model.ID).SingleOrDefault();
                Mapper.Map<UserLocationDO, UserLocation>(model, dbObject);
            }

            rep.DCP.CommitChanges(userID);
            Mapper.Map<UserLocation, UserLocationDO>(dbObject, model);
        }
开发者ID:NGITechnology,项目名称:BeymenCheckout,代码行数:24,代码来源:UserLocationBL.cs

示例7: AddOrderItemToNotFoundList

        public static void AddOrderItemToNotFoundList(OrderItemDO orderItemDO, int locationId, int userId)
        {
            CollectionDataDO collectionDataDO = CollectionDataBL.CreateCollectionDataIfNotExist(locationId, userId);

            ValidateLocation(locationId, collectionDataDO.Location.ID);

            CheckoutDataContextProvider dcp = CheckoutDataContextProvider.Instance;

            OrderItemDO orderItem = CheckoutBL.GetOrderItemById(orderItemDO.ID);

            if (SupplyRuleEngine.CanOrderItemBeAddedToNotFoundList(collectionDataDO, orderItem))
            {
                Repository<CollectionOrderItem> rep = new Repository<CollectionOrderItem>(dcp);
                CollectionOrderItem collectionOrderItem = new CollectionOrderItem();
                collectionOrderItem.OrderItemID = orderItemDO.ID;
                collectionOrderItem.StatusCode = OrderItemStatus.NotFound.ToString();
                collectionOrderItem.CollectionDataID = collectionDataDO.ID;
                collectionOrderItem.NotFoundReasonID = orderItemDO.NotFoundReasonID;
                rep.InsertOnSubmit(collectionOrderItem);
                dcp.CommitChanges(userId);
            }
        }
开发者ID:NGITechnology,项目名称:BeymenCheckout,代码行数:22,代码来源:CollectionDataBL.cs

示例8: AddOrderItemListToFoundList

        public static void AddOrderItemListToFoundList(List<int> orderItemIdList, int locationId, int userId)
        {
            CollectionDataDO collectionDataDO = CollectionDataBL.CreateCollectionDataIfNotExist(locationId, userId);
            ValidateLocation(locationId, collectionDataDO.Location.ID);
            CheckoutDataContextProvider dcp = CheckoutDataContextProvider.Instance;
            List<OrderItemDO> orderItemList = CheckoutBL.GetOrderItemListByIdList(orderItemIdList);

            foreach (var orderItem in orderItemList)
            {
                if (SupplyRuleEngine.CanOrderItemBeAddedToFoundList(collectionDataDO, orderItem))
                {
                    Repository<CollectionOrderItem> rep = new Repository<CollectionOrderItem>(dcp);
                    CollectionOrderItem collectionOrderItem = new CollectionOrderItem();
                    collectionOrderItem.OrderItemID = orderItem.ID;
                    collectionOrderItem.StatusCode = OrderItemStatus.Found.ToString();
                    collectionOrderItem.CollectionDataID = collectionDataDO.ID;
                    rep.InsertOnSubmit(collectionOrderItem);
                }
            }

            dcp.CommitChanges(userId);
        }
开发者ID:NGITechnology,项目名称:BeymenCheckout,代码行数:22,代码来源:CollectionDataBL.cs


注:本文中的Repository.InsertOnSubmit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。