示例#1
0
        //
        // GET: /Carrier/

        public ActionResult Index()
        {
            using (var bll = new CarrierBll())
            {
                IEnumerable <tbCarrier> list = bll.Find(t => t.Deleted == false).ToList();
                return(View(list));
            }
        }
示例#2
0
 public ActionResult Edit(int id)
 {
     using (var bll = new CarrierBll())
     {
         tbCarrier carrier = bll.Find(id);
         return(View(carrier));
     }
 }
示例#3
0
 public ActionResult New()
 {
     using (var bll = new CarrierBll())
     {
         TempData["carriers"] = bll.Find(t => t.Deleted == false).OrderBy(t => t.NickName).Select(t => new SelectListItem {
             Text = t.NickName, Value = t.Id.ToString()
         }).ToList();
         return(View());
     }
 }
示例#4
0
 public ActionResult Delete(int id)
 {
     using (var bll = new CarrierBll())
     {
         tbCarrier carrier = bll.Find(id);
         bll.Delete(carrier);
         bll.Save();
         return(RedirectToAction("Index"));
     }
 }
示例#5
0
 public ActionResult Edit(tbRate model)
 {
     try
     {
         if (!ModelState.IsValid)
         {
             using (var bll = new CarrierBll())
             {
                 TempData["carriers"] = bll.Find().OrderBy(t => t.NickName).Select(t => new SelectListItem {
                     Text = t.NickName, Value = t.Id.ToString()
                 }).ToList();
                 TempData["Exists"] = true;
                 var msg = string.Join("<br>", ModelState.Where(t => t.Value.Errors.Count > 0).Select(t => t.Value.Errors[0].ErrorMessage));
                 TempData["Message"] = msg;
                 return(View(model));
             }
         }
         model.IdUser = LoggedUserModel.idUser ?? 0;
         using (var bll = new RateBll())
         {
             model.Rate = Convert.ToDecimal(model.Rate);
             bll.Update(model);
             bll.Save();
         }
         TempData["Exists"]  = true;
         TempData["Message"] = "Rate successfully registered!";
         return(RedirectToAction("Index"));
     }
     catch (MyException ex)
     {
         using (var bll = new CarrierBll())
         {
             TempData["carriers"] = bll.Find().OrderBy(t => t.NickName).Select(t => new SelectListItem {
                 Text = t.NickName, Value = t.Id.ToString()
             }).ToList();
             TempData["Exists"]  = true;
             TempData["Message"] = ex.Message;
             return(View(model));
         }
     }
     catch (Exception ex)
     {
         using (var bll = new CarrierBll())
         {
             TempData["carriers"] = bll.Find().OrderBy(t => t.NickName).Select(t => new SelectListItem {
                 Text = t.NickName, Value = t.Id.ToString()
             }).ToList();
             TempData["Exists"]  = true;
             TempData["Message"] = ex.Message;
             return(View(model));
         }
     }
 }