public ActionResult Create(FormCollection fc, CMS_Services obj, HttpPostedFileBase file) { try { TempData.Keep("TypeOfMap"); if (ModelState.IsValid) { CMS_Services_DAO objDAO = new CMS_Services_DAO(); CSF_Users_DAO objUserDao = new CSF_Users_DAO(); int intUserID = objUserDao.GetUserIDByUserName(HttpContext.User.Identity.Name); obj.UserCreate = intUserID; int ReturnID = objDAO.Insert(obj); if (ReturnID > 0) { SetAlert("Thêm services thành công", AlertType.Success); return(RedirectToAction("Index", "CMS_Services")); } else { ModelState.AddModelError("", "Thêm services 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()); } }
public ActionResult Edit(FormCollection fc, CMS_Services obj, HttpPostedFileBase file) { try { TempData.Keep("TypeOfMap"); if (ModelState.IsValid) { CMS_Services_DAO objDAO = new CMS_Services_DAO(); if (objDAO.Update(obj)) { SetAlert("Cập nhật services thành công", AlertType.Success); return(RedirectToAction("Index", "CMS_Services")); } else { SetAlert("Cập nhật services 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()); } }
public JsonResult putExtent(string xMin, string yMin, string xMax, string yMax) { var jsonResults = new Object(); int idMap = Int32.Parse(Session["idMap"].ToString()); var idservice = MyContext.CMS_MapService.Where(b => b.MapID == idMap).Select(b => b.ServiceID).FirstOrDefault(); CMS_Services objService = MyContext.CMS_Services.SingleOrDefault(s => s.ID == idservice); objService.XMin = xMin; objService.YMin = yMin; objService.XMax = xMax; objService.YMax = yMax; WebApp.Core.DAO.CMS_Services_DAO objDAO = new WebApp.Core.DAO.CMS_Services_DAO(); objDAO.Update(objService); return(Json(jsonResults, JsonRequestBehavior.AllowGet)); }
public int Insert(CMS_Services entity) { try { entity.CreateDate = System.DateTime.Now; MyContext.CMS_Services.Add(entity); MyContext.SaveChanges(); return(entity.ID); } catch (Exception ex) { Logs.WriteLog(ex); throw; } }
public bool Update(CMS_Services entity) { try { CMS_Services obj = MyContext.CMS_Services.Find(entity.ID); obj.Name = entity.Name; obj.Description = entity.Description; obj.URL = entity.URL; obj.Publish = entity.Publish; obj.Source = entity.Source; obj.XMax = entity.XMax; obj.XMin = entity.XMin; obj.YMax = entity.YMax; obj.YMin = entity.YMin; obj.TypeOfMapID = entity.TypeOfMapID; MyContext.SaveChanges(); return(true); } catch (Exception ex) { Logs.WriteLog(ex); return(false); } }