public IList <UserInfo> GetUsers(Guid ticket) { IList <UserInfo> users; try { _loginQuery.IsAuthenticated(ticket); _sessionGenerator.ProlongSession(ticket); users = _userQuery.GetUsers(); } catch (SecurityException e) { throw new FaultException <SecurityException>(e); } catch (Exception e) { throw new FaultException(e.Message); } return(users); }
public void AddUser(AddUserRequest request) { var isAdmin = _loginQueryDao.GetUser(request.Ticket).IsAdmin; if (!isAdmin) { throw new Exception("User is not admin therefore cannot add users"); } var taken = _userQuery.GetUsers().Count(x => x.Login == request.Login.Trim()); if (taken > 0) { throw new Exception("Login already in use"); } using (var session = NHibernateHelper.OpenSession()) { using (var transaction = session.BeginTransaction()) { var entity = new Users { IsAdmin = request.IsAdmin, Name = request.Name, Login = request.Login, Password = request.Password, Surname = request.Surname, Unit = new Unit { Id = request.UnitId } }; session.Save(entity); transaction.Commit(); } } }
public async Task <List <GetUserDto> > GetUsers(int pageIndex, int pageSize) { return(await _UserQuery.GetUsers(pageIndex, pageSize)); }
public async Task <ActionResult <UserDto[]> > GetUsers([FromQuery] string[] userName) => await _userQuery.GetUsers(userName);