public IResult LoginUser(string username, string password) { var result = new Result { Operation = Operation.Read, Status = Status.Success }; try { var user = _userRepository.LoginUser(username, password); if (user != null) { var userView = new UserViewModel(); userView.MapFromModel(user, "UserName;"); userView.FullName = user.FirstName + " " + user.LastName; var firstOrDefault = user.UserRoles.FirstOrDefault(); if (firstOrDefault != null) { userView.Role = firstOrDefault.Role.Name; } userView.ApprovalDetail = _approvalRepository.GetApprovalEventsOfUserForOpening(user.UserId); result.Body = userView; } else { result.Message = UserStatusNotification.InValidUser; result.Status = Status.Fail; } } catch (Exception e) { result.Message = e.Message; result.Status = Status.Fail; result.Status = Status.Error; } return(result); }