public GetUserResponse GetUser(GetUserRequest request) { try { var user = DataContext.Users.Include(u => u.Role).First(x => x.Id == request.Id); var response = user.MapTo<GetUserResponse>(); //Mapper.Map<GetUserResponse>(user); //response.RoleName = DataContext.RoleGroups.FirstOrDefault(x => x.Id == user.RoleId).Name.ToString(); return response; } catch (System.InvalidOperationException x) { return new GetUserResponse { IsSuccess = false, Message = x.Message }; } }
public GetUserResponse GetUserByEmail(GetUserRequest request) { try { var user = DataContext.Users.Include(u => u.Role).First(x => x.Email == request.Email); var response = user.MapTo<GetUserResponse>(); //Mapper.Map<GetUserResponse>(user); response.IsSuccess = true; return response; } catch (System.InvalidOperationException x) { return new GetUserResponse { IsSuccess = false, Message = x.Message }; } }
public ActionResult ValidateEmail(GetUserRequest request) { var response = new GetUserResponse(); response = _userService.GetUserByEmail(new GetUserRequest { Email = request.Email }); if (response.IsSuccess) { return Json(true, JsonRequestBehavior.AllowGet); } else { return Json(false, JsonRequestBehavior.AllowGet); } }