public ActionResult Add(tbl_GroupUser obj) { try { _groupUserRepository.Add(obj); return(Json(new { IsSuccess = true, Messenger = "Thêm mới nhóm thành công", }, JsonRequestBehavior.AllowGet)); } catch (Exception) { return(Json(new { IsSuccess = false, Messenger = string.Format("Thêm mới nhóm thất bại") }, JsonRequestBehavior.AllowGet)); } }
public ActionResult Edit(tbl_GroupUser obj) { try { var objOld = _groupUserRepository.Find(obj.ID); objOld.Name = obj.Name; objOld.Status = obj.Status; objOld.ExpandNews = obj.ExpandNews; _groupUserRepository.Edit(objOld); return(Json(new { IsSuccess = true, Messenger = "Cập nhật danh mục thành công", }, JsonRequestBehavior.AllowGet)); } catch (DbEntityValidationException e) { foreach (var eve in e.EntityValidationErrors) { Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:", eve.Entry.Entity.GetType().Name, eve.Entry.State); foreach (var ve in eve.ValidationErrors) { Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage); } } throw; } /*catch (Exception) * { * return Json(new * { * IsSuccess = false, * Messenger = string.Format("Cập nhật danh mục thất bại") * }, JsonRequestBehavior.AllowGet); * }*/ }
public ActionResult Search(tbl_GroupUser obj, int page = 1) { var lstGroupUser = _groupUserRepository.GetAll(); if (!string.IsNullOrEmpty(obj.Name)) { lstGroupUser = lstGroupUser.Where( g => HelperString.UnsignCharacter(g.Name.ToLower().Trim()) .Contains(HelperString.UnsignCharacter(obj.Name).ToLower().Trim())); } var totalRecord = lstGroupUser.Count(); lstGroupUser = lstGroupUser.Skip((page - 1) * Webconfig.RowLimit).Take(Webconfig.RowLimit).ToList(); return(Json(new { viewContent = RenderViewToString("~/Areas/Admin/Views/GroupUser/_ListData.cshtml", lstGroupUser), totalPages = Math.Ceiling(((double)totalRecord / Webconfig.RowLimit)), }, JsonRequestBehavior.AllowGet)); }