///<summary> ///Implements IUserManagemetService.UpdateDog ///</summary> public void UpdateDog(Guid dogId, DogForUpdate dogForUpdate) { if (dogForUpdate.Equals(null)) { throw new ArgumentNullException(); } using (var connection = new SqlConnection(_connectionString)) { connection.Open(); var query = @"UPDATE Dog SET Name = @Name, Age = @Age, Specifics = @Specifics, ProfilePicturePath = @ProfilePicturePath WHERE Id = @Id;"; connection.Execute(query, new { Name = dogForUpdate.Name, Age = dogForUpdate.Age, Specifics = dogForUpdate.Specifics, ProfilePicturePath = dogForUpdate.ProfilePicturePath, Id = dogId }); } }
public void UpdateDog_PutQuerySuccessfullyExecuted_ReturnsOkObjectResult() { var id = Guid.NewGuid(); var dog = new DogForUpdate(); var userManagementServiceMock = new Mock <IUserManagementService>(); userManagementServiceMock.Setup(x => x.UpdateDog(id, dog)); var userManagementController = new UserManagementController(userManagementServiceMock.Object); var result = userManagementController.Update(id, dog); Assert.IsTrue(result.GetType() == typeof(OkObjectResult)); }
public IActionResult Update(Guid id, DogForUpdate dogForUpdate) { try { _userManagementService.UpdateDog(id, dogForUpdate); return(Ok(new { Success = true })); } catch (Exception exception) { return(new ObjectResult(new { Error = exception.Message }) { StatusCode = StatusCodes.Status500InternalServerError }); } }