public bool AssignRoleToUser(ApplicationEntity application, UserEntity user, RolesEntity role) { try { using (IUnitOfWork uow = _UnitFactory.GetUnit(this)) { uow.BeginTransaction(); if (!uow.Query<AppUserRoleEntity>().Any(x => x.ApplicationId.Equals(application.IdApplication) && x.RoleId.Equals(role.Id) && x.UserId.Equals(user.Id))) { AppUserRoleEntity app = new AppUserRoleEntity(); app.ApplicationId = app.ApplicationId; app.RoleId = role.Id; app.UserId = user.Id; uow.SaveOrUpdate(app); uow.Commit(); return true; } } } catch (Exception err) { //TODO:Add log here return false; } return true; }
public bool Save(RolesEntity rolesEntity) { try { using (IUnitOfWork uow = _UnitFactory.GetUnit(this)) { uow.BeginTransaction(); uow.SaveOrUpdate(rolesEntity); uow.Commit(); } return true; } catch (Exception err) { //TODO: log here: } return false; }