public async Task <HttpResponseMessage> GetAllAsync(PagingModel _params) { var Res = Request.CreateResponse(); var Result = new Res(); try { var data = await Task.Run(() => _userProfileService.GetAll(_params)); if (data != null) { Result.Data = data; Result.Status = true; Result.Message = "Call API Success"; Result.StatusCode = HttpStatusCode.OK; } else { Result.Data = null; Result.Status = false; Result.Message = "Không tìm thấy dữ liệu"; Result.StatusCode = HttpStatusCode.InternalServerError; } Res.Content = new StringContent(JsonConvert.SerializeObject(Result)); return(Res); } catch (Exception ex) { throw new Exception(ex.Message); } }
public void GetAll_Empty() { this.mockRepository.Setup(x => x.Get( It.IsAny <Expression <Func <UserProfile, bool> > >(), It.IsAny <Func <IQueryable <UserProfile>, IOrderedQueryable <UserProfile> > >(), It.IsAny <string>())).Returns(new List <UserProfile>()); var services = new UserProfileService(this.mockRepository.Object); services.GetAll().Should().BeEmpty(); }
public ActionResult Index() { var data = userProfileService.GetAll(); return(View(data)); }