public long SaveRole(ClsRole objSave) { try { long roleId = 0; using (TransactionScope scope = new TransactionScope()) { using (this.objDataContext = new RoleDataContext(Functions.StrConnection)) { var result = this.objDataContext.InsertOrUpdateRole(objSave.lgId, objSave.strRoleName, objSave.strDescription, objSave.blAllowKilometerLimit, objSave.lgCompanyID, mySession.Current.UserId, PageMaster.Role, objSave.blAllowDispatchBackDateEntry).FirstOrDefault(); if (result != null) { roleId = result.InsertedId; foreach (var item in objSave.strRights.Split(',')) { string[] strRight = item.Split('|'); this.objDataContext.InsertOrUpdateRolePermissions(strRight[0].longSafe(), roleId, strRight[1].longSafe(), strRight[2].boolSafe(), strRight[3].boolSafe(), strRight[4].boolSafe(), strRight[5].boolSafe(), strRight[6].boolSafe(), mySession.Current.UserId, PageMaster.Role); } } } scope.Complete(); } return(roleId); } catch (Exception ex) { Functions.Write(ex, System.Reflection.MethodBase.GetCurrentMethod().Name, PageMaster.Role, mySession.Current.UserId); return(0); } }
public ClsRole GetRoleByRoleId(long lgRoleId) { ClsRole objClsRole = new ClsRole(); try { using (this.objDataContext = new RoleDataContext(Functions.StrConnection)) { GetRoleByIdResult item = this.objDataContext.GetRoleById(lgRoleId).FirstOrDefault(); if (item != null) { objClsRole.lgId = item.Id; objClsRole.strRoleName = item.RoleName; objClsRole.strDescription = item.DESCRIPTION; objClsRole.blAllowKilometerLimit = Convert.ToBoolean(item.AllowKilometerLimit); objClsRole.blAllowDispatchBackDateEntry = Convert.ToBoolean(item.AllowDispatchBackDateEntry); objClsRole.lgCompanyID = Convert.ToInt32(item.CompanyID); } } } catch (Exception ex) { Functions.Write(ex, System.Reflection.MethodBase.GetCurrentMethod().Name, PageMaster.Role, mySession.Current.UserId); } return(objClsRole); }