Пример #1
0
 public ActionResult Create(CMS_ReservationViewModels model)
 {
     try
     {
         if (!ModelState.IsValid)
         {
             Response.StatusCode = (int)HttpStatusCode.BadRequest;
             return(PartialView("_Create", model));
         }
         var msg = "";
         model.CreatedBy = CurrentUser.UserId;
         model.UpdatedBy = CurrentUser.UserId;
         var result = _fac.CreateOrUpdate(model, ref msg);
         if (result)
         {
             return(RedirectToAction("Index"));
         }
         ModelState.AddModelError("CustomerName", msg);
         Response.StatusCode = (int)HttpStatusCode.BadRequest;
         return(PartialView("_Create", model));
     }
     catch (Exception ex)
     {
         Response.StatusCode = (int)HttpStatusCode.BadRequest;
         return(PartialView("_Create", model));
     }
 }
Пример #2
0
 public ActionResult Index(CMS_ReservationViewModels model)
 {
     try
     {
         if (!ModelState.IsValid || model.IsSuccess == true)
         {
             model.ListProducts  = _facProduct.GetList((byte)CMS_Common.Commons.EProductType.Procudure);
             model.ListCustomer  = _facCus.GetList();
             model.ListEmployees = _facEmp.GetList();
             Response.StatusCode = (int)HttpStatusCode.BadRequest;
             return(View(model));
         }
         var msg    = "";
         var result = _fac.CreateOrUpdate(model, ref msg);
         if (result)
         {
             model           = new CMS_ReservationViewModels();
             model.IsSuccess = true;
             return(RedirectToAction("Success"));
         }
         else
         {
             model.IsSuccess = false;
             return(View(model));
         }
     }
     catch (Exception ex)
     {
         NSLog.Logger.Error("Reservation Index", ex);
         return(new HttpStatusCodeResult(400, ex.Message));
     }
 }