public static FullItem AssembleFullItem(BLL.Interfaces.IItem item, string language)
 {
     return(new FullItem
     {
         Code = item.Code,
         Price = item.Price,
         Name = AssembleName(item.Names, language),
         MainImageName = ItemUtils.getMainImageName(item.Code),
         AdditionalImages = ItemUtils.GetItemAdditionalImageNames(item.Code)
     });
 }
Exemple #2
0
        public ActionResult ChangeItem(string code)
        {
            IItem  item    = itemService.getItemByCode(code);
            string ruName  = null;
            string ukrName = null;
            string engName = null;

            foreach (IItemName itemName in item.Names)
            {
                switch (itemName.LanguageType)
                {
                case LanguageType.English:
                    engName = itemName.Name;
                    break;

                case LanguageType.Russian:
                    ruName = itemName.Name;
                    break;

                case LanguageType.Ukrainian:
                    ukrName = itemName.Name;
                    break;

                default:
                    string exceptionMessage = $"Not supported value {itemName.LanguageType.ToString()} of field IItemName.LanguageType";
                    logger.Error(exceptionMessage);
                    throw new NotSupportedException(exceptionMessage);
                }
            }


            IEnumerable <string> itemAdditionalImageNames = ItemUtils.GetItemAdditionalImageNames(code);
            string mainImageName = ItemUtils.getMainImageName(code);


            ChangeItemViewModel viewModel = new ChangeItemViewModel(Guid.NewGuid().ToString(), item.Code, item.Price.ToString(),
                                                                    WebAssembler.Assemble(item.Category), ruName, ukrName, engName, mainImageName, categories, itemAdditionalImageNames);

            return(View(viewModel));
        }