public ActionResult Add(AddPriceList postPrice, HttpPostedFileBase PricePath)
        {
            if (ModelState.IsValid && (PricePath != null && PricePath.ContentLength > 0))
            {
                PriceList newPrice = new PriceList();

                newPrice.Title      = postPrice.Title;
                newPrice.UploadDate = DateTime.Now;
                newPrice.CompanyId  = AppSettings.CurrentCompany;

                /*Сохранение фото*/
                var fileName   = Path.GetFileName(PricePath.FileName);
                var savingPath = Path.Combine(HttpContext.Server.MapPath(priceUploadDirectory), fileName);
                PricePath.SaveAs(savingPath);
                newPrice.Path = VirtualPathUtility.ToAbsolute(Path.Combine(priceUploadDirectory, fileName));

                _priceListRepository.Insert(newPrice);
                _priceListRepository.SaveChanges();

                return(RedirectToAction("GetAll"));
                //throw new HttpException(403, "Forbidden");
            }
            else
            {
                return(View(postPrice));
            }
        }
Example #2
0
        public Shop(int id, string name, string adr, string supplyList)
        {
            ShopId   = id;
            ShopName = name;
            Adress   = adr;
            AddPriceList newPriceList = new AddPriceList();

            Products = newPriceList.SetPriceList(supplyList);
        }