public void UnitTestUpdateMemberRecords() { // Add reecord _memberrequest.AddNewMemberEntry( "Bill", "Blogs", "*****@*****.**", "0229230292", DateTime.Parse("1990-10-12"), "Active" ); // Retrieve record. Member member = _memberrequest.GetMemberEntry(1); int key = 0; if (member != null) { key = member.ID; } else { Assert.Fail("Cannot retrieve Member record"); } string valueToUpdate = "Bob"; // Update record. _memberrequest.EditMemberEntry( key, valueToUpdate, member.LastName, member.EmailAddress, member.ContactNumber, member.DateOfBirth, member.AccountStatus ); // Retrieve updated record. member = _memberrequest.GetMemberEntry(1); key = 0; if (member != null) { key = member.ID; } else { Assert.Fail("Cannot retrieve updated Member record"); } Assert.IsTrue(member.FirstName == valueToUpdate); }
public IActionResult Update(int id, [FromBody] MemberViewModel mvm) { if (mvm != null) { _memberrequest.EditMemberEntry( id, mvm.FirstName, mvm.LastName, mvm.EmailAddress, mvm.ContactNumber, mvm.DateOfBirth, mvm.AccountStatus ); // return the updated Item to the client. return(new JsonResult(_objectmapper.Map <MemberViewModel>(mvm), DefaultJsonSettings)); } else { // return a HTTP Status 404 (Not Found) if we couldn't find a suitable Member. return(NotFound(new { Error = String.Format("Member ID {0} has not been found", id) })); } }