コード例 #1
0
        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);
        }
コード例 #2
0
 public ActionResult DeleteLot(LotModel lotmodel)
 { 
     cabinetservice.DeleteLot(lotmodel.Name);
     return RedirectToAction("ListAllLotNames");
 }
コード例 #3
0
 public ViewResult EditLot(LotModel lotmodel)
 {
     ViewBag.name = lotmodel.Name;
     ViewBag.Cathegories = cabinetservice.GetAllCathegoryNames().Where(name => name != "Все категории");
     return View("UpdateLot",lotmodel);
 }
コード例 #4
0
 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);
 }
コード例 #5
0
ファイル: Maper.cs プロジェクト: Titof2123709/Auction2
 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;
 }