public IActionResult Update(MateUpdate mateUpdate) { int?mateID = ClaimHelper.GetIdFromClaimIdentity((ClaimsIdentity)this.ControllerContext.HttpContext.User.Identity); if (mateID == null) { return(Unauthorized(new ErrorMessageModel("Utilizador não existe!"))); } Mate mate = _mapper.Map <Mate>(mateUpdate); MateDAO mateDAO = new MateDAO(_connection); mateDAO.Update(mate, (int)mateID); return(Ok(new SuccessMessageModel("Atualizado com sucesso!"))); }
public void CanMateUpdateProfileTest() { IMateDAO <Mate> MateDAO = new MateDAO(_connection); Mate testMate = new Mate(); testMate.FirstName = "Jessica"; testMate.LastName = "Coelho"; testMate.UserName = "******"; testMate.Password = "******"; testMate.Email = "*****@*****.**"; testMate.Description = "Lorem Ipsum is simply dummy text of the printing and typesetting industry."; testMate.Address = "Ordem"; testMate.Categories = new[] { Categories.FURNITURE_ASSEMBLE, Categories.TRANSPORTATION }; testMate.Rank = Ranks.MATE; testMate.Range = 20; Mate returned = MateDAO.Create(testMate); returned.FirstName = "Ema"; returned.LastName = "Coelho"; returned.UserName = "******"; returned.Description = "Sou um mate!"; returned.Address = "Lousada"; returned.Range = 40; Mate updated = MateDAO.Update(returned, returned.Id); Assert.Equal(returned.FirstName, updated.FirstName); Assert.Equal(returned.LastName, updated.LastName); Assert.Equal(returned.UserName, updated.UserName); Assert.Equal(returned.Description, updated.Description); Assert.Equal(returned.Address, updated.Address); Assert.Equal(returned.Range, updated.Range); _fixture.Dispose(); }