public ActionResult CreateLot(LotModel lotmodel) { if (ModelState.IsValid) { lotmodel.Statys = Statys.InProcess; if (cabinetservice.GetLotByName(lotmodel.Name) == null) { var blllot = Maper.ToBllLot(lotmodel); blllot.CathegoryId = cabinetservice.GetCathegoryIdByName(lotmodel.Cathegory); cabinetservice.CreateLot(blllot); var LotId = cabinetservice.GetLotIdByName(lotmodel.Name); ViewBag.LotId = LotId; return View("ImageLoad"); } else ModelState.AddModelError("", "Лот с таким названием уже существует"); } else ModelState.AddModelError("", "Incorrect input Data"); ViewBag.Cathegories = cabinetservice.GetAllCathegoryNames().Where(name => name != "Все категории"); return View(lotmodel); }
public ActionResult DeleteLot(LotModel lotmodel) { cabinetservice.DeleteLot(lotmodel.Name); return RedirectToAction("ListAllLotNames"); }
public ViewResult EditLot(LotModel lotmodel) { ViewBag.name = lotmodel.Name; ViewBag.Cathegories = cabinetservice.GetAllCathegoryNames().Where(name => name != "Все категории"); return View("UpdateLot",lotmodel); }
public ActionResult UpdateLot(LotModel lotmodel) { if (ModelState.IsValid) { var blllot = Maper.ToBllLot(lotmodel); blllot.CathegoryId = cabinetservice.GetCathegoryIdByName(lotmodel.Cathegory); cabinetservice.UpdateLot(blllot); return RedirectToAction("ListAllLotNames"); } else ModelState.AddModelError("", "Incorrect input data"); return View(lotmodel); }
internal static BllLot ToBllLot(LotModel lotmodel) { if(lotmodel!=null) return new BllLot() { Id = lotmodel.Id, UserId = Convert.ToInt32(((ClaimsPrincipal)Thread.CurrentPrincipal).Claims.Where(c => c.Type == ClaimTypes.NameIdentifier).Select(c => c.Value).SingleOrDefault()), TimeBegin = lotmodel.TimeBegin, StatysId = (int)lotmodel.Statys, StartPrice = lotmodel.StartPrice, Name = lotmodel.Name, EndPrice = lotmodel.EndPrice, Description = lotmodel.Description, DateBegin = lotmodel.DateBegin, BuyerName = lotmodel.BuyerName }; return null; }