public ActionResult Create(CreateLotViewModel createLot, HttpPostedFileBase uploadImage) { if (ModelState.IsValid) { if (uploadImage != null) { uploadImage.SaveAs( Server.MapPath("~/Content/Image/" + System.IO.Path.GetFileName(uploadImage.FileName))); createLot.LotImageUrl = "/Content/Image/" + System.IO.Path.GetFileName(uploadImage.FileName); } var lot = Mapper.Map <CreateLotViewModel, Lot>(createLot); lot.StarLotSaleDate = DateTime.Today; lot.CurrentPrice = lot.StartLotPrice; lot.IsSold = false; var currentCustomer = dataBase.Customers.GetByName(User.Identity.Name); CustomerLot customerLot = new CustomerLot() { Lot = lot, LotId = lot.LotId, Customer = currentCustomer, CustomerId = currentCustomer.CustomerId, CustomerBet = 0, LotMaker = true, WinAuction = false }; dataBase.CustomerLots.Create(customerLot); dataBase.Save(); return(RedirectToAction("Index", "Customer")); } else { ModelState.AddModelError("", "Данные введены некоректно. Пожалуйста исправте ошибки!"); } return(View("AddNewLot", createLot)); }
public void Update(CustomerLot item) { context.Entry(item).State = EntityState.Modified; }
public void Create(CustomerLot item) { context.CustomerLots.Add(item); }