public JsonResult SavePermission(SystemPermission objPermission) { if (objPermission.PermissionID > 0) // Update { if (!AppGlobal.Services.BusinessPermission.IsExistPermission(objPermission.PermissionID)) { ErrorMessages.Add(new Mobile.Core.Mvc.Error() { Message = "Your request is not exist" }); return Json(new { suceess = 0, ErrorMessages = ErrorMessages }); } objPermission.ModifiedBy = MobileAuthentication.UserId; if (string.IsNullOrEmpty(objPermission.PermissionName)) { ErrorMessages.Add(new Mobile.Core.Mvc.Error() { Message = "Please enter the permission name" }); return Json(new { success = 0, errormessages = ErrorMessages }); } var result = AppGlobal.Services.BusinessPermission.UpdatePermission(objPermission); return Json(new { success = result ? 1 : 0 , errormessage = ErrorMessages}); } else // Add new { objPermission.CreatedBy = MobileAuthentication.User.UserId; objPermission.CreatedDate = DateTime.Now; if (string.IsNullOrEmpty(objPermission.PermissionName)) { ErrorMessages.Add(new Mobile.Core.Mvc.Error() { Message = "Please enter the permission name" }); return Json(new { success = 0, errormessages = ErrorMessages }); } var result = AppGlobal.Services.BusinessPermission.AddPermission(objPermission); return Json(new { success = result ? 1 : 0, errormessages = ErrorMessages }); } }
public bool AddPermission(SystemPermission objPermission) { try { repPermission.Add(objPermission); SaveChanges(); return true; } catch { return false; } }
public bool UpdatePermission(SystemPermission objPermission) { try { var existObj = GetPermission(objPermission.PermissionID); existObj.ModifiedDate = DateTime.Now; existObj.PermissionName = objPermission.PermissionName; existObj.ModifiedBy = objPermission.ModifiedBy; repPermission.Update(existObj); SaveChanges(); return true; } catch { return false; } }