示例#1
0
        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
                    };
            }
        }
示例#2
0
文件: UserService.cs 项目: fazar/Pear
 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
         };
     }
 }
示例#3
0
 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);
     }
 }