Esempio n. 1
0
        public BaseResponse <VMUserResponse> Get(VMGetUserDetailsRequest vmRequest)
        {
            if (vmRequest == null)
            {
                return(BaseResponse <VMUserResponse> .SetError("Request body is empty"));
            }

            try
            {
                var result         = _userService.Get(vmRequest);
                var responseObject = VMUserListItem.ToResponse(result);
                var response       = BaseResponse <VMUserResponse> .SetResponse(responseObject);

                return(response);
            }
            catch (Exception exc)
            {
                return(BaseResponse <VMUserResponse> .SetError(exc));
            }
        }
Esempio n. 2
0
        public VMUserDetails Get(VMGetUserDetailsRequest vmrequest)
        {
            var user = _context.Users
                       .Where(x => x.UserId == vmrequest.UserId)
                       .Select(x => new VMUserDetails
            {
                UserId    = x.UserId,
                Email     = x.Email,
                Password  = x.Password,
                FirstName = x.FirstName,
                LastName  = x.LastName,
            }).FirstOrDefault();

            if (user == null)
            {
                throw new Exception("User could not be found.");
            }
            else
            {
                return(user);
            }
        }