public void CanGetMateWithoutDescriptionByIdTest() { IMateDAO <Mate> MateDAO = new MateDAO(_connection); Mate testMate = new Mate(); testMate.FirstName = "Jessica"; testMate.LastName = "Coelho"; testMate.UserName = "******"; testMate.Password = "******"; testMate.Email = "*****@*****.**"; testMate.Address = "Ordem"; testMate.Categories = new[] { Categories.FURNITURE_ASSEMBLE, Categories.TRANSPORTATION }; testMate.Rank = Ranks.MATE; testMate.Range = 20; Mate returnedMate = MateDAO.Create(testMate); Mate m = MateDAO.FindMateById(returnedMate.Id); Assert.Equal(returnedMate.Id, m.Id); Assert.Equal(returnedMate.UserName, m.UserName); Assert.Equal(returnedMate.FirstName, m.FirstName); Assert.Equal(returnedMate.LastName, m.LastName); Assert.Equal(returnedMate.Email, m.Email); Assert.Equal(returnedMate.Address, m.Address); _fixture.Dispose(); }
public ActionResult <List <JobPostReturnedModel> > GetAvailableWorks([FromQuery(Name = "categories")] Categories[] categories, [FromQuery(Name = "address")] string address, [FromQuery(Name = "distance")] int?distance, [FromQuery(Name = "rating")] int?rating) { try { int?mateID = ClaimHelper.GetIdFromClaimIdentity((ClaimsIdentity)this.ControllerContext.HttpContext.User.Identity); if (mateID == null) { return(NotFound(new ErrorMessageModel("Utilizador não existe!"))); } MateDAO mateDao = new MateDAO(_connection); Mate mate = mateDao.FindMateById((int)mateID); if (address == null) { address = mate.Address; } IJobDAO jobDAO = new JobDAO(_connection); List <JobPostReturnedModel> postsList = _mapper.Map <List <JobPostReturnedModel> >(jobDAO.GetJobs(categories, address, distance, rating, (int)mateID)); return(Ok(postsList)); } catch (Exception ex) { return(UnprocessableEntity(new ErrorMessageModel(ex.Message))); } }
public ActionResult <MateProfileModel> GetMateById(int id) { MateDAO mateDAO = new MateDAO(_connection); MateProfileModel returned = _mapper.Map <MateProfileModel>(mateDAO.FindMateById(id)); return(Ok(returned)); }
public ActionResult <List <MateReviewsModel> > MateReviewsList(int id) { int?EmployerID = ClaimHelper.GetIdFromClaimIdentity((ClaimsIdentity)this.ControllerContext.HttpContext.User.Identity); // caso o employerId seja nulo if (EmployerID == null) { return(Unauthorized(new ErrorMessageModel("Utilizador não existe!"))); } MateDAO mateDao = new MateDAO(_connection); if (mateDao.FindMateById(id) == null) { return(NotFound(new ErrorMessageModel("Mate não Encontrado"))); } ReviewMateDAO reviewDao = new ReviewMateDAO(_connection); List <MateReviewsModel> reviewsList = reviewDao.MateReviewsList(id); return(Ok(reviewsList)); }