コード例 #1
0
        public async Task <ActionResult> AddHookahTobacco(HookahTobaccoViewModel htvm)
        {
            if (ModelState.IsValid)
            {
                HookahTobaccoDTO tobacco = new HookahTobaccoDTO();
                await productService.AddHookahTobacco(tobacco);

                return(RedirectToAction("AddProduct"));
            }
            else
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
        }
コード例 #2
0
        public async Task <OperationDetails> AddHookahTobacco(HookahTobaccoDTO htDto)
        {
            try
            {
                HookahTobacco tobacco = new HookahTobacco()
                {
                    Mark        = htDto.Mark,
                    Model       = htDto.Model,
                    Description = htDto.Description,
                    Country     = htDto.Country,
                    Weight      = htDto.Weight,
                    Price       = htDto.Price
                };
                //db.HookahTobacco.Add(tobacco);
                await db.SaveAsync();

                return(new OperationDetails(true, "Товар успешно добавлен", ""));
            }
            catch
            {
                return(new OperationDetails(false, "При добавлении товара произошла ошибка", ""));
            }
        }