Пример #1
0
 public IItem getItemByCode(string code)
 {
     DAL.Entities.Item found = repository.ItemRepository.GetAll().
                               Where(item => item.Code == code).
                               Include(item => item.Names).
                               FirstOrDefault();
     return(Assembler.Assemble(found));
 }
Пример #2
0
 private DAL.Entities.OrderItem AssembleItem(ICreateOrderItemData item, IEnumerable <DAL.Entities.Item> items)
 {
     DAL.Entities.Item foundItem = items.First(i => i.Code == item.Code);
     return(new DAL.Entities.OrderItem
     {
         Item = foundItem,
         Count = item.Count,
         Price = foundItem.Price
     });
 }
Пример #3
0
        public string createItem(IBriefItem item)
        {
            DAL.Entities.Item assembled = new DAL.Entities.Item
            {
                Code       = itemCodeGenerator.generateCode(),
                Price      = item.Price,
                Category   = Assembler.Assemble(item.Category),
                AddingTime = DateTime.UtcNow,
                Names      = Assembler.Assemble(item.Names)
            };
            repository.ItemRepository.Create(assembled);
            repository.Save();

            return(assembled.Code);
        }
Пример #4
0
        public void changeItem(IChangeItemData itemData)
        {
            DAL.Entities.Item foundItem = repository.ItemRepository.GetAll().Include(item => item.Names).
                                          First(item => item.Code == itemData.Code);

            if (itemData.NewPrice != null)
            {
                foundItem.Price = itemData.NewPrice.Value;
            }
            if (itemData.NewCategory != null)
            {
                foundItem.Category = Assembler.Assemble(itemData.NewCategory.Value);
            }
            foreach (DAL.Entities.ItemName itemName in foundItem.Names)
            {
                switch (itemName.LanguageType)
                {
                case DAL.Entities.LanguageType.English:
                    if (!string.IsNullOrEmpty(itemData.NewEnName))
                    {
                        itemName.Name = itemData.NewEnName;
                    }
                    break;

                case DAL.Entities.LanguageType.Russian:
                    if (!string.IsNullOrEmpty(itemData.NewRuName))
                    {
                        itemName.Name = itemData.NewRuName;
                    }
                    break;

                case DAL.Entities.LanguageType.Ukrainian:
                    if (!string.IsNullOrEmpty(itemData.NewUkName))
                    {
                        itemName.Name = itemData.NewUkName;
                    }
                    break;
                }
            }

            repository.ItemRepository.Update(foundItem);
            repository.Save();
        }
Пример #5
0
 public static IItem Assemble(DAL.Entities.Item item)
 {
     return(new Item(item.Code, item.Price, Assemble(item.Category), item.AddingTime, Assemble(item.Names)));
 }
Пример #6
0
 public void deleteItemByCode(string code)
 {
     DAL.Entities.Item foundItem = repository.ItemRepository.GetAll().First(item => item.Code == code);
     repository.ItemRepository.Delete(foundItem.Id);
     repository.Save();
 }