Exemplo n.º 1
0
 public ActionResult Create(FormCollection fc, CMS_TypeOfMap obj, HttpPostedFileBase file)
 {
     try
     {
         if (ModelState.IsValid)
         {
             CMS_TypeOfMap_DAO objDAO = new CMS_TypeOfMap_DAO();
             int ReturnID             = objDAO.Insert(obj);
             if (ReturnID > 0)
             {
                 SetAlert("Thêm loại bản đồ thành công", AlertType.Success);
                 return(RedirectToAction("Index", "CMS_TypeOfMap"));
             }
             else
             {
                 ModelState.AddModelError("", "Thêm loại bản đồ không thành công");
             }
             return(View("Index"));
         }
         return(View());
     }
     catch (Exception ex)
     {
         SetAlert("Lỗi" + ex.Message.ToString(), AlertType.Error);
         Logs.WriteLog(ex);
         return(View());
     }
 }
Exemplo n.º 2
0
 public ActionResult Edit(FormCollection fc, CMS_TypeOfMap obj, HttpPostedFileBase file)
 {
     try
     {
         if (ModelState.IsValid)
         {
             CMS_TypeOfMap_DAO objDAO = new CMS_TypeOfMap_DAO();
             if (objDAO.Update(obj))
             {
                 SetAlert("Cập nhật loại bản đồ thành công", AlertType.Success);
                 return(RedirectToAction("Index", "CMS_TypeOfMap"));
             }
             else
             {
                 SetAlert("Cập nhật loại bản đồ không thành công", AlertType.Error);
             }
         }
         return(View(obj));
     }
     catch (Exception ex)
     {
         SetAlert("Lỗi" + ex.Message.ToString(), AlertType.Error);
         Logs.WriteLog(ex);
         return(View());
     }
 }
Exemplo n.º 3
0
 public int Insert(CMS_TypeOfMap entity)
 {
     try
     {
         MyContext.CMS_TypeOfMap.Add(entity);
         MyContext.SaveChanges();
         return(entity.ID);
     }
     catch (Exception ex)
     {
         Logs.WriteLog(ex);
         throw;
     }
 }
Exemplo n.º 4
0
 public bool Update(CMS_TypeOfMap entity)
 {
     try
     {
         CMS_TypeOfMap obj = MyContext.CMS_TypeOfMap.Find(entity.ID);
         obj.Name        = entity.Name;
         obj.Description = entity.Description;
         MyContext.SaveChanges();
         return(true);
     }
     catch (Exception ex)
     {
         Logs.WriteLog(ex);
         return(false);
     }
 }