/// <summary> /// Shows how to Update an existing record by Primary Key /// </summary> private void Update() { // first instantiate a new RoleMaster RoleMaster objRoleMaster = new RoleMaster(); // assign the existing primary key(s) // of the record you want updated objRoleMaster.RoleId = 1; // assign values you want updated objRoleMaster.RoleDescription = "Administrator"; objRoleMaster.CreatedOn = DateTime.Now; objRoleMaster.CreatedBy = "System"; objRoleMaster.ModifiedOn = DateTime.Now; objRoleMaster.ModifiedBy = "abc"; // finally, update an existing record objRoleMaster.Update(); }
public ActionResult Delete(Guid UniqueId, RoleMaster roleMaster) { var rolemaster = roleMasterService.FindBy(x => x.UniqueId == UniqueId).FirstOrDefault(); try { rolemaster.DeletedBy = User.Identity.Name; rolemaster.DeletedDate = DateTime.Now; roleMasterService.Delete(rolemaster); roleMasterService.Save(); // TODO: Add delete logic here return(RedirectToAction("Index")); } catch { return(View(rolemaster)); } }
/// <summary> /// Shows how to Select a record by Primary Key. It also shows how to retrieve Lazily-loaded related Objects. Related Objects are assigned for each Foreign Key. /// </summary> private void SelectByPrimaryKey() { int roleIdSample = 1; // select a record by primary key(s) RoleMaster objRoleMaster = RoleMaster.SelectByPrimaryKey(roleIdSample); if (objRoleMaster != null) { // if record is found, a record is returned int roleId = objRoleMaster.RoleId; string roleDescription = objRoleMaster.RoleDescription; DateTime createdOn = objRoleMaster.CreatedOn; string createdBy = objRoleMaster.CreatedBy; DateTime?modifiedOn = objRoleMaster.ModifiedOn; string modifiedBy = objRoleMaster.ModifiedBy; } }
/// <summary> /// Shows how to get all records based on Search Parameters sorted by column name in either ascending or descending order. /// </summary> private void SelectAllDynamicWhereWithSortExpression() { // search parameters, everything is nullable, only items being searched for should be filled // note: fields with String type uses a LIKE search, everything else uses an exact match // also, every field you're searching for uses the AND operator // e.g. int? productID = 1; string productName = "ch"; // will translate to: SELECT....WHERE productID = 1 AND productName LIKE '%ch%' int? roleId = null; string roleDescription = null; DateTime?createdOn = null; string createdBy = null; DateTime?modifiedOn = null; string modifiedBy = null; string sortBy = "RoleId"; // ascending order //string sortBy = "RoleId desc"; // descending order List <RoleMaster> objRoleMasterCol = RoleMaster.SelectAllDynamicWhere(roleId, roleDescription, createdOn, createdBy, modifiedOn, modifiedBy, sortBy); }
public int?AddRoleMaster(RoleMaster roleMaster) { try { int?result = -1; if (roleMaster != null) { roleMaster.CreateDate = DateTime.Now; _context.RoleMasters.Add(roleMaster); _context.SaveChanges(); result = roleMaster.RoleId; } return(result); } catch (Exception) { throw; } }
private void submitBtn_Click(object sender, RoutedEventArgs e) { UserMasterDAO usrMasterDAOREf = new UserMasterDAOImpl(); UserMaster usrMasterref = new UserMaster(); usrMasterref.username = userNameTxt.Text; usrMasterref.mobileNo = mobileNoTxt.Text; usrMasterref.address = adressTxt.Text; if (maleRbtn.IsChecked == true) { usrMasterref.gender = "M"; } else if (femaleRbtn.IsChecked == true) { usrMasterref.gender = "F"; } usrMasterref.emailId = emailidTxt.Text; if (dobCalender.SelectedDate.HasValue) { usrMasterref.dob = dobCalender.SelectedDate.Value; Console.WriteLine("DOB:{0}\n", usrMasterref.dob); } if (pwdtxt.Password == cpwd.Password) { usrMasterref.pwd = pwdtxt.Password; } RoleMaster r = new RoleMaster(); r.roleName = DesgcomboBox.Text; usrMasterref.designationRef = r; byte[] images = null; FileStream stream = new FileStream(imglocation, FileMode.Open, FileAccess.Read); BinaryReader brs = new BinaryReader(stream); images = brs.ReadBytes((int)stream.Length); if (images == null) { MessageBox.Show("Upload image!"); } usrMasterref.picture = images; usrMasterDAOREf.insertUser(usrMasterref); }
private void searchUserNameBtn_Click(object sender, RoutedEventArgs e) { UserMaster usrmasterRef = new UserMaster(); usrmasterRef.username = UserNameTxt.Text.Trim(); RoleMaster rolemasterRef = new RoleMaster(); rolemasterRef.roleName = null; usrmasterRef.designationRef = rolemasterRef; UserMasterDAO userMasterDaoRef = new UserMasterDAOImpl(); List <string> listNm = new List <string>(); listNm.Add("user Id"); listNm.Add("User Name"); listNm.Add("Mobile No"); listNm.Add("Address"); listNm.Add("gender"); listNm.Add("Email Id"); listNm.Add("DOB"); listNm.Add("password"); listNm.Add("designation"); List <List <string> > itemList = new List <List <string> >(); List <ArrayList> usrList = new List <ArrayList>(); usrList = userMasterDaoRef.getUsrList(usrmasterRef); DataTable dt = CreateDataTable(listNm, usrList); dataGridUser.ItemsSource = dt.DefaultView; dataGridUser.Columns[0].IsReadOnly = true; dataGridUser.Columns[1].IsReadOnly = false; dataGridUser.Columns[2].IsReadOnly = false; dataGridUser.Columns[3].IsReadOnly = false; dataGridUser.Columns[4].IsReadOnly = false; dataGridUser.Columns[5].IsReadOnly = false; dataGridUser.Columns[6].IsReadOnly = false; dataGridUser.Columns[7].IsReadOnly = false; dataGridUser.Columns[8].IsReadOnly = true; roleNameTxt.Text = ""; }
public RoleMaster findbyprimaryKey(string roleName) { DataBaseconnection DbCon = new DataBaseconnection(); string qry = "select * from dbo.order_role where rolename= '" + roleName + "';"; SqlConnection cnn = DbCon.ObtainConnection(); // MessageBox.Show("Connectiom established !!"); SqlDataAdapter da = new SqlDataAdapter(); SqlCommand cmd = new SqlCommand(qry, cnn); // da.InsertCommand = new SqlCommand(qry, cnn); // da.InsertCommand.ExecuteReader(); SqlDataReader reader = cmd.ExecuteReader(); RoleMaster roleMasterref = new RoleMaster(); if (reader.HasRows) { while (reader.Read()) { Console.WriteLine("\n inserted values \n"); Console.WriteLine("{0}\t{1}\n", reader.GetString(0), reader.GetString(1)); roleMasterref.roleName = reader.GetString(0); roleMasterref.roleDesc = reader.GetString(1); } } else { Console.WriteLine("No rows found."); } Console.WriteLine("{0}\t{1}\n", roleMasterref.roleName, roleMasterref.roleDesc); reader.Close(); // MessageBox.Show("display successfull !!"); cnn.Dispose(); cnn.Close(); // MessageBox.Show("Connectiom closed !!"); return(roleMasterref); }
public async Task <Guid> SaveStatus(RoleDTO _Dto, Guid Id, int EntityState) { RoleMaster _RoleMaster = new RoleMaster(); _RoleMaster = await db.RoleMasters.Where(o => o.Id == Id).FirstOrDefaultAsync(); if (_RoleMaster.StatusCode == EMPConstants.InActive) { _RoleMaster.StatusCode = EMPConstants.Active; } else if (_RoleMaster.StatusCode == EMPConstants.Active) { _RoleMaster.StatusCode = EMPConstants.InActive; } if (EntityState == (int)System.Data.Entity.EntityState.Modified) { _RoleMaster.LastUpdatedDate = DateTime.Now; _RoleMaster.LastUpdatedBy = _Dto.UserId; db.Entry(_RoleMaster).State = System.Data.Entity.EntityState.Modified; } try { await db.SaveChangesAsync(); db.Dispose(); return(_RoleMaster.Id); } catch (DbUpdateConcurrencyException) { if (!IsExists(_RoleMaster.Id)) { return(Guid.Empty); } else { throw; } } }
// GET: RoleMaster/Edit/5 public ActionResult Edit(int?id) { try { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } RoleMaster roleMaster = _iRole.GetRoleMasterById(id); if (roleMaster == null) { return(HttpNotFound()); } return(View(roleMaster)); } catch (Exception) { throw; } }
public ActionResult Edit(RoleMaster model) { try { model.Cre_on = Convert.ToDateTime(TempData["Cre_on"]); //model.Cre_By = Guid.Parse(Session["loginid"].ToString()); model.Modified_On = DateTime.UtcNow; model.Modified_by = Guid.Parse(Session["loginid"].ToString()); model.isActive = true; db.Entry(model).State = EntityState.Modified; db.SaveChanges(); return(Json("success")); } catch (Exception ex) { string Url = Request.Url.AbsoluteUri; _Log.createLog(ex, "-->Role Edit Post" + Url); throw; } }
public int?UpdateRoleMaster(RoleMaster roleMaster) { try { int?result = -1; if (roleMaster != null) { roleMaster.CreateDate = DateTime.Now; _context.Entry(roleMaster).State = EntityState.Modified; _context.SaveChanges(); result = roleMaster.RoleId; } return(result); } catch (Exception) { throw; } }
public ActionResult GetRoleById(int id) { try { var team = db.RoleMasters.Find(id); RoleMaster master = new RoleMaster(); master.RoleId = id; master.RoleName = team.RoleName; master.Cre_on = team.Cre_on; master.Cre_By = team.Cre_By; TempData["Cre_on"] = team.Cre_on; return(Json(master, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { string Url = Request.Url.AbsoluteUri; _Log.createLog(ex, "-->GetRoleById" + Url); throw; } }
public async Task <IActionResult> Create(RoleMaster roleMaster) { if (ModelState.IsValid) { IdentityResult roleResult; var roleExist = await _roleManager.RoleExistsAsync(roleMaster.Name); if (!roleExist) { //create the roles and seed them to the database: Question 1 roleResult = await _roleManager.CreateAsync(new IdentityRole(roleMaster.Name)); } //_context.Add(roleMaster); //await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(roleMaster)); }
public int DeleteRoldata(RoleMaster r) { int n = 0; try { IRoleMasterDA objRol = new RoleMasterDA(); n = Convert.ToInt32(objRol.DeleteRoleMasterdata(r)); } catch (Exception ex) { } finally { } return(n); }
public PageResult LoadPage(int id, string returnUrl) { // select a record by primary key(s) CourseEnquiryAPI.BusinessObject.RoleMaster objRoleMaster = RoleMaster.SelectByPrimaryKey(id); // create the model used by the partial page AddEditRoleMasterPartialModel model = new AddEditRoleMasterPartialModel(); model.Operation = CrudOperation.Update; model.ReturnUrl = returnUrl; model.RoleMaster = objRoleMaster; // assign values to the model used by this page PartialModel = model; // assign the return url ReturnUrl = returnUrl; return(Page()); }
public IActionResult GetRoleByID(int roleID) { try { //_logger.LogInfo("Fetching all the roles from the storage"); RoleMaster role = _roleService.GetRolebyId(roleID); RoleViewModel roleVM = Mapper.Map <RoleViewModel>(role); // _logger.LogInfo($"Returning {role} roles."); return(Ok(role)); } catch (Exception ex) { throw ex; //_logger.LogError($"Something went wrong: {ex}"); //return StatusCode(500, "Internal server error"); } }
private void searchdesgBtn_Click(object sender, EventArgs e) { UserMaster usrmasterRef = new UserMaster(); usrmasterRef.username = ""; RoleMaster rolemasterRef = new RoleMaster(); rolemasterRef.roleName = searchdesgTxt.Text; Console.WriteLine("inside else if \nRole Name:{0}", rolemasterRef.roleName); usrmasterRef.designationRef = rolemasterRef; Console.WriteLine("in user edit \nRole Name:{0}", usrmasterRef.designationRef.roleName); UserMasterDao userMasterDaoRef = new UserMasterDAOImpl(); List <string> listNm = new List <string>(); listNm.Add("user Id"); listNm.Add("User Name"); listNm.Add("Mobile No"); listNm.Add("Address"); listNm.Add("gender"); listNm.Add("Email Id"); listNm.Add("DOB"); listNm.Add("password"); listNm.Add("designation"); // List<List<string>> itemList = new List<List<string>>(); List <ArrayList> usrList = new List <ArrayList>(); usrList = userMasterDaoRef.getUsrList(usrmasterRef); dataGridVieweditUsr.DataSource = CreateDataTable(listNm, usrList); dataGridVieweditUsr.Columns[0].ReadOnly = true; dataGridVieweditUsr.Columns[1].ReadOnly = false; dataGridVieweditUsr.Columns[2].ReadOnly = false; dataGridVieweditUsr.Columns[3].ReadOnly = false; dataGridVieweditUsr.Columns[4].ReadOnly = false; dataGridVieweditUsr.Columns[5].ReadOnly = false; dataGridVieweditUsr.Columns[6].ReadOnly = false; dataGridVieweditUsr.Columns[7].ReadOnly = false; dataGridVieweditUsr.Columns[8].ReadOnly = true; dataGridVieweditUsr.FirstDisplayedScrollingRowIndex = dataGridVieweditUsr.RowCount - 1; // dataGridVieweditUsr.FirstDisplayedScrollingRowIndex = dataGridVieweditUsr.ColumnCount - 1; }
public ActionResult UserMaster() { UserMaster objUserMaster = new UserMaster(); #region Menu Access By on Role Int32 intResult = 0; // bool PPorNonPP = false; objUserMaster = (UserMaster)Session["LoggedInUser"]; var Result = objSP_PRICINGEntities.VALIDATE_MENU_BY_ROLE(objUserMaster.RoleID, "AMUM"); intResult = Convert.ToInt32(Result.SingleOrDefault()); if (intResult == 0) { return(RedirectToAction("UserNotAuthorize", "Login")); } #endregion List <RoleMaster> RoleMasterList = new List <RoleMaster>(); ObjectResult <RoleResult> objRoleResult = objSP_PRICINGEntities.SP_FETCH_ROLE_MASTER_DETAILS(); List <RoleResult> RoleResultList = objRoleResult.ToList(); if (RoleResultList != null && RoleResultList.Count > 0) { foreach (RoleResult oRoleResult in RoleResultList) { RoleMaster objRoleMaster = new RoleMaster(); General.ReflectSingleData(objRoleMaster, oRoleResult); RoleMasterList.Add(objRoleMaster); } } objUserMaster.RoleList = RoleMasterList; return(View(objUserMaster)); }
private void LoadFromId(int roleMasterId) { if (CachedEntityCommander.IsTypeRegistered(typeof(RoleMasterInfo))) { RoleMasterInfo roleMasterInfo = Find(GetList(), roleMasterId); if (roleMasterInfo == null) { throw new AppException("未能在缓存中找到相应的键值对象"); } Copy(roleMasterInfo, this); } else { RoleMaster roleMaster = new RoleMaster(roleMasterId); if (roleMaster.IsNew) { throw new AppException("尚未初始化"); } LoadFromDAL(this, roleMaster); } }
public ActionResult Edit(RoleMaster rolemaster, string userid) { try { if (ModelState.IsValid) { IRM.Update(rolemaster, Session["userid"].ToString()); } return(RedirectToAction("Index")); } catch { return(View()); } //if (ModelState.IsValid) //{ // IRM.Update(rolemaster, Session["userid"].ToString()); //} //return View(rolemaster); }
public RoleMaster[] GetRoles() { DataTable dt = new DataTable(); RoleMaster[] roleMasters; Query = "exec proc_GetRoles"; dt = caObjects.ExecuteQueryReturnDataTable(Query); roleMasters = new RoleMaster[dt.Rows.Count]; for (int i = 0; i <= dt.Rows.Count - 1; i++) { RoleMaster roleMaster = new RoleMaster(); roleMaster.rm_RoleId = Convert.ToInt32(dt.Rows[i]["rm_RoleId"]); roleMaster.rm_RoleName = Convert.ToString(dt.Rows[i]["rm_RoleName"]); roleMaster.rm_Status = Convert.ToBoolean(dt.Rows[i]["rm_Status"]); roleMasters[i] = roleMaster; } return(roleMasters); }
public JsonResult FetchRoleDetails() { List <RoleMaster> RoleMasterList = new List <RoleMaster>(); ObjectResult <RoleResult> objRoleResult = objSP_PRICINGEntities.SP_FETCH_ROLE_MASTER_DETAILS(); List <RoleResult> RoleResultList = objRoleResult.ToList(); if (RoleResultList != null && RoleResultList.Count > 0) { foreach (RoleResult oRoleResult in RoleResultList) { RoleMaster objRoleMaster = new RoleMaster(); General.ReflectSingleData(objRoleMaster, oRoleResult); RoleMasterList.Add(objRoleMaster); } } var RoleMasterListData = RoleMasterList.ToList(); return(Json(RoleMasterListData, JsonRequestBehavior.AllowGet)); }
public List <string> getRoleName() { DataBaseconnection DbCon = new DataBaseconnection(); string qry = "select * from dbo.order_role"; SqlConnection cnn = DbCon.ObtainConnection(); // MessageBox.Show("Connectiom established !!"); SqlDataAdapter da = new SqlDataAdapter(); SqlCommand cmd = new SqlCommand(qry, cnn); SqlDataReader reader = cmd.ExecuteReader(); RoleMaster roleRef = new RoleMaster(); List <string> roleNames = new List <string>(); if (reader.HasRows) { while (reader.Read()) { Console.WriteLine("\n inserted values \n"); Console.WriteLine("{0}\t\n", reader.GetString(0)); roleNames.Add(reader.GetString(0)); } } else { Console.WriteLine("couldn't display"); } reader.Close(); // MessageBox.Show("display successfull !!"); cnn.Dispose(); cnn.Close(); // MessageBox.Show("Connectiom closed !!"); return(roleNames); }
public HttpResponseMessage CreateRole(RoleMaster objRole, string Token, string AppKey) { string strJson = string.Empty; var response = this.Request.CreateResponse(HttpStatusCode.OK); try { Accountmeg objaccountmegment = new Accountmeg(); string result = objaccountmegment.Getresult(AppKey, Token); if (result == "true") { using (TTPAPIDataContext DB = new TTPAPIDataContext()) { RoleMaster objRoleMaster = new RoleMaster(); objRoleMaster.RoleName = objRole.RoleName; objRoleMaster.RoleDesc = objRole.RoleDesc; objRoleMaster.CreatedDateTime = DateTime.Now; objRoleMaster.CreatedBy = String.Format("{0}{1}", Token.Substring(0, 36), DateTime.Now.ToShortDateString()); DB.RoleMasters.InsertOnSubmit(objRoleMaster); DB.SubmitChanges(); strJson = "{\"Result\":\"" + objRoleMaster.RoleId + "\"}"; response.Content = new StringContent(strJson, Encoding.UTF8, "application/json"); return(response); } } else { strJson = "{\"Result\":\"Invalide AppKey\"}"; response.Content = new StringContent(strJson, Encoding.UTF8, "application/json"); return(response); } } catch (Exception ex) { strJson = "{\"Result\":\"" + ex.Message + "\"}"; response.Content = new StringContent(strJson, Encoding.UTF8, "application/json"); return(response); } }
public IActionResult DeleteRole(int id = 0) { try { RoleMaster objAdmin = _context.RoleMaster.FirstOrDefault(x => x.RoleId == id); if (objAdmin != null) { objAdmin.IsActive = false; _context.Entry(objAdmin).State = EntityState.Modified; _context.SaveChanges(); return(Ok(new { success = "true", ReturnMsg = "Role deleted successfully.", PartialviewContent = "" })); } else { return(Ok(new { success = "false", ReturnMsg = "Role does not exist." })); } } catch (Exception ex) { return(Ok(new { success = "false", ReturnMsg = ex })); } }
public PageResult LoadPage(int id, string returnUrl) { // select a record by primary key(s) CourseEnquiry1API.BusinessObject.UserRoles objUserRoles = UserRoles.SelectByPrimaryKey(id); // create the model used by the partial page AddEditUserRolesPartialModel model = new AddEditUserRolesPartialModel(); model.UserMasterDropDownListData = UserMaster.SelectUserMasterDropDownListData(); model.RoleMasterDropDownListData = RoleMaster.SelectRoleMasterDropDownListData(); model.Operation = CrudOperation.Update; model.ReturnUrl = returnUrl; model.UserRoles = objUserRoles; // assign values to the model used by this page PartialModel = model; // assign the return url ReturnUrl = returnUrl; return(Page()); }
//[CustomAuthorization("ReportUploader,ReportCreater", "Create,Delete")] public ActionResult RoleActionEdit(int id, RoleMaster rolemaster, int[] actions) { if (ModelState.IsValid) { try { _ObjRoleActionRepository.UpdateAction(id, rolemaster, actions); return(RedirectToAction("RoleActionIndex")); } catch (DbEntityValidationException dbEx) { foreach (var validationErrors in dbEx.EntityValidationErrors) { foreach (var validationError in validationErrors.ValidationErrors) { System.Console.WriteLine("Property: {0} Error: {1}", validationError.PropertyName, validationError.ErrorMessage); } } } } return(RedirectToAction("RoleAction", "RoleActionIndex")); }
public IActionResult EditRole(int id, [FromBody] RoleViewModel roleVM) { try { RoleMaster role = null; role = Mapper.Map <RoleMaster>(roleVM); role = _roleService.GetRolebyId(id); role.RoleID = id; role.RoleID = roleVM.RoleID; role.RoleName = roleVM.RoleName; role.RoleDescription = roleVM.RoleDescription; role.IsActive = roleVM.IsActive; role.CreatedBy = roleVM.CreatedBy; role.CreatedDate = roleVM.CreatedDate; return(Ok(role)); } catch (Exception ex) { return(BadRequest(new { message = ex.Message })); } }
/// <summary> /// Shows how to Select all records by RoleMaster, related to column RoleId /// </summary> private void SelectUserRolesCollectionByRoleId() { int roleIdSample = 1; List <UserRoles> objUserRolesCol = UserRoles.SelectUserRolesCollectionByRoleId(roleIdSample); // Example 1: you can optionally sort the collection in ascending order by your chosen field objUserRolesCol.Sort(UserRoles.ByUserId); // Example 2: to sort in descending order, add this line to the Sort code in Example 1 objUserRolesCol.Reverse(); // Example 3: directly bind to a GridView - for ASP.NET Web Forms // GridView grid = new GridView(); // grid.DataSource = objUserRolesCol; // grid.DataBind(); // Example 4: loop through all the UserRoles(s) foreach (UserRoles objUserRoles in objUserRolesCol) { int userRoleId = objUserRoles.UserRoleId; int? userId = objUserRoles.UserId; int? roleId = objUserRoles.RoleId; bool?status = objUserRoles.Status; // get the UserMaster related to UserId. if (objUserRoles.UserId != null) { UserMaster objUserMasterRelatedToUserId = UserMaster.SelectByPrimaryKey(userId.Value); } // get the RoleMaster related to RoleId. if (objUserRoles.RoleId != null) { RoleMaster objRoleMasterRelatedToRoleId = RoleMaster.SelectByPrimaryKey(roleId.Value); } } }
private void LoadFromId(int roleMasterId) { if (CachedEntityCommander.IsTypeRegistered(typeof(RoleMasterInfo))) { RoleMasterInfo roleMasterInfo=Find(GetList(), roleMasterId); if(roleMasterInfo==null) throw new AppException("未能在缓存中找到相应的键值对象"); Copy(roleMasterInfo, this); } else { RoleMaster roleMaster=new RoleMaster( roleMasterId); if(roleMaster.IsNew) throw new AppException("尚未初始化"); LoadFromDAL(this, roleMaster); } }
//从后台获取数据 internal static void LoadFromDAL(RoleMasterInfo pRoleMasterInfo, RoleMaster pRoleMaster) { pRoleMasterInfo.roleMasterId = pRoleMaster.RoleMasterId; pRoleMasterInfo.roleId = pRoleMaster.RoleId; pRoleMasterInfo.masterId = pRoleMaster.MasterId; pRoleMasterInfo.isPass = pRoleMaster.IsPass; pRoleMasterInfo.Loaded=true; }
/// <summary> /// 保存 /// </summary> public override void Save() { if(!m_Loaded)//新增 { RoleMaster roleMaster=new RoleMaster(); SaveToDb(this, roleMaster,true); } else//修改 { RoleMaster roleMaster=new RoleMaster(roleMasterId); if(roleMaster.IsNew) throw new AppException("该数据已经不存在了"); SaveToDb(this, roleMaster,false); } }
//数据持久化 internal static void SaveToDb(RoleMasterInfo pRoleMasterInfo, RoleMaster pRoleMaster,bool pIsNew) { pRoleMaster.RoleMasterId = pRoleMasterInfo.roleMasterId; pRoleMaster.RoleId = pRoleMasterInfo.roleId; pRoleMaster.MasterId = pRoleMasterInfo.masterId; pRoleMaster.IsPass = pRoleMasterInfo.isPass; pRoleMaster.IsNew=pIsNew; string UserName = SubsonicHelper.GetUserName(); try { pRoleMaster.Save(UserName); } catch(Exception ex) { LogManager.getInstance().getLogger(typeof(RoleMasterInfo)).Error(ex); if(ex.Message.Contains("插入重复键"))//违反了唯一键 { throw new AppException("此对象已经存在");//此处等待优化可以从唯一约束中直接取出提示来,如果没有的话,默认为原始的出错提示 } throw new AppException("保存失败"); } pRoleMasterInfo.roleMasterId = pRoleMaster.RoleMasterId; //如果缓存存在,更新缓存 if (CachedEntityCommander.IsTypeRegistered(typeof(RoleMasterInfo))) { ResetCache(); } }