/// <summary> /// Deprecated Method for adding a new object to the TblRoles EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToTblRoles(TblRole tblRole) { base.AddObject("TblRoles", tblRole); }
public ActionResult Save(RoleViewModel roleViewModel) { try { if (ModelState.IsValid) { //add if (roleViewModel.RoleId == 0 && roleViewModel.ActionName == "Add") { var model = new TblRole() { RoleId = roleViewModel.RoleId, RoleName = roleViewModel.RoleName, Description = roleViewModel.Description, ApplicationId = roleViewModel.ApplicationId, ModuleId = roleViewModel.ModuleId }; //_roleRepository.Insert(model); } else if (roleViewModel.ActionName == "Edit") //edit { TblRole role = _roleRepository.GetById(roleViewModel.RoleId); if (role != null) { role.RoleId = roleViewModel.RoleId; role.RoleName = roleViewModel.RoleName; role.Description = roleViewModel.Description; role.ApplicationId = roleViewModel.ApplicationId; role.ModuleId = roleViewModel.ModuleId; //_roleRepository.Update(role); } else { return Content(KendoUiHelper.GetKendoUiWindowAjaxSuccessMethod(Boolean.FalseString, roleViewModel.ActionName, MessageType.warning.ToString(), ExceptionHelper.ExceptionMessageForNullObject())); } } //_roleRepository.Save(); return Content(KendoUiHelper.GetKendoUiWindowAjaxSuccessMethod(Boolean.TrueString, roleViewModel.ActionName, MessageType.success.ToString(), "Saved Successfully.")); } return Content(KendoUiHelper.GetKendoUiWindowAjaxSuccessMethod(Boolean.FalseString, roleViewModel.ActionName, MessageType.warning.ToString(), ExceptionHelper.ModelStateErrorFormat(ModelState))); } catch (Exception ex) { return Content(KendoUiHelper.GetKendoUiWindowAjaxSuccessMethod(Boolean.FalseString, roleViewModel.ActionName, MessageType.warning.ToString(), ExceptionHelper.ExceptionMessageFormat(ex))); } }
/// <summary> /// Create a new TblRole object. /// </summary> /// <param name="roleName">Initial value of the RoleName property.</param> /// <param name="roleId">Initial value of the RoleId property.</param> /// <param name="applicationId">Initial value of the ApplicationId property.</param> /// <param name="moduleId">Initial value of the ModuleId property.</param> public static TblRole CreateTblRole(global::System.String roleName, global::System.Int32 roleId, global::System.Int32 applicationId, global::System.Int32 moduleId) { TblRole tblRole = new TblRole(); tblRole.RoleName = roleName; tblRole.RoleId = roleId; tblRole.ApplicationId = applicationId; tblRole.ModuleId = moduleId; return tblRole; }