public IQueryable <ModelUserRole> GetUserRolesByUser(string username) { if (string.IsNullOrWhiteSpace(username)) { throw new Exception("An error occured and user could not be identified."); } var model = new ModelUserRole(); return(model.Get(_ctx).Where(x => x.UserRoleActive == true && x.Username == username)); }
public ModelUserRole GetUserRole(string username, string rolename) { if (string.IsNullOrWhiteSpace(username)) { throw new Exception("An error occured and user could not be identified."); } if (string.IsNullOrWhiteSpace(rolename)) { throw new Exception("An error occured and role could not be identified."); } var model = new ModelUserRole(); return(model.Get(_ctx).FirstOrDefault(x => x.UserRoleActive == true && x.Username == username && x.RoleName == rolename)); }
public void CreateUserRole(ModelUserRole model) { using (var transaction = _ctx.Database.BeginTransaction()) { try { model.UserRoleActive = true; var entity = model.ToEntity(); _ctx.Insert(entity); _ctx.SaveChanges(); transaction.Commit(); } catch (Exception e) { transaction.Rollback(); throw new ArgumentException(e.Message); } } }
public void UpdateUserRole(ModelUserRole model) { using (var transaction = _ctx.Database.BeginTransaction()) { try { var entity = _ctx.UserRoles.FirstOrDefault(x => x.URID == model.URID); model.Update(entity); _ctx.Update(entity); _ctx.SaveChanges(); transaction.Commit(); } catch (Exception e) { transaction.Rollback(); throw new ArgumentException(e.Message); } } }
public void CreateUserRole(ModelUserRole model, string username, string rolename) { //using (var transaction = _ctx.Database.BeginTransaction()) //{ try { model.UserRoleActive = true; model.Username = username; model.RoleName = rolename; var entity = model.ToEntity(); _ctx.Insert(entity); _ctx.SaveChanges(); //transaction.Commit(); } catch (Exception e) { //transaction.Rollback(); throw new ArgumentException(e.Message); } //} }
public ModelUserRole GetUserRole(int urid) { var model = new ModelUserRole(); return(model.Get(_ctx).FirstOrDefault(x => x.URID == urid)); }
public IQueryable <ModelUserRole> ReadUserRoles() { var model = new ModelUserRole(); return(model.Get(_ctx)); }