Example #1
0
 public ActionResult Delete(LocationModels model)
 {
     try
     {
         string msg    = "";
         var    result = _factory.DeleteLocation(model.ID, ref msg);
         if (!result)
         {
             ModelState.AddModelError("Name", msg);
             Response.StatusCode = (int)HttpStatusCode.BadRequest;
             return(PartialView("_Delete", model));
         }
         HttpCookie _LocationCookie = Request.Cookies["LocCookie"];
         //if (_LocationCookie == null)
         //{
         //    HttpCookie cookie = new HttpCookie("LocCookie");
         //    cookie.Expires = DateTime.Now.AddYears(10);
         //}
         LocationFactory _facLoc = new LocationFactory();
         var             _loc    = _facLoc.GetListLocation().Select(x => new LocationSession
         {
             Id   = x.ID,
             Name = x.Name
         }).ToList();
         if (_loc != null && _loc.Any())
         {
             string     myObjectJson = JsonConvert.SerializeObject(_loc); //new JavaScriptSerializer().Serialize(userSession);
             HttpCookie cookie       = new HttpCookie("LocCookie");
             cookie.Expires = DateTime.Now.AddYears(10);
             cookie.Value   = Server.UrlEncode(myObjectJson);
             Response.Cookies.Add(cookie);
         }
         return(new HttpStatusCodeResult(HttpStatusCode.OK));
     }
     catch (Exception ex)
     {
         NSLog.Logger.Error("Xóa khu vực: ", ex);
         ModelState.AddModelError("Name", ("Lỗi khi xóa thông tin khu vực!"));
         Response.StatusCode = (int)HttpStatusCode.BadRequest;
         return(PartialView("_Delete", model));
     }
 }
Example #2
0
 public ActionResult Delete(LocationModels model)
 {
     try
     {
         string msg    = "";
         var    result = _factory.DeleteLocation(model.ID, ref msg);
         if (!result)
         {
             ModelState.AddModelError("Name", msg);
             Response.StatusCode = (int)HttpStatusCode.BadRequest;
             return(PartialView("_Delete", model));
         }
         return(new HttpStatusCodeResult(HttpStatusCode.OK));
     }
     catch (Exception ex)
     {
         NSLog.Logger.Error("Xóa khu vực: ", ex);
         ModelState.AddModelError("Name", ("Lỗi khi xóa thông tin khu vực!"));
         Response.StatusCode = (int)HttpStatusCode.BadRequest;
         return(PartialView("_Delete", model));
     }
 }