public HttpResponseMessage Put(int id, [FromBody] MemberRegistrationViewModel member) { if (ModelState.IsValid) { var storedMemberid = _memberRegistration.CheckNameExitsforUpdate(member.MemberFName, member.MemberLName, member.MemberMName); if (storedMemberid == member.MemberId || storedMemberid == 0) { var automember = AutoMapper.Mapper.Map <MemberRegistration>(member); automember.JoiningDate = DateTime.Now; var result = _memberRegistration.UpdateMember(automember); if (result > 0) { var response = new HttpResponseMessage() { StatusCode = HttpStatusCode.OK // Status code: 200 }; return(response); } else { var response = new HttpResponseMessage() { StatusCode = HttpStatusCode.BadRequest // Status code: 400 }; return(response); } } else { var response = new HttpResponseMessage() { StatusCode = HttpStatusCode.Conflict // Status code: 409 }; return(response); } } else { var response = new HttpResponseMessage() { StatusCode = HttpStatusCode.BadRequest // Status code: 400 }; return(response); } }
public IActionResult Put(int id, [FromBody] MemberRegistrationViewModel member) { if (ModelState.IsValid) { var storedMemberid = _memberRegistration.CheckNameExitsforUpdate(member.MemberFName, member.MemberLName, member.MemberMName); if (storedMemberid == member.MemberId || storedMemberid == 0) { var automember = AutoMapper.Mapper.Map <MemberRegistration>(member); automember.JoiningDate = DateTime.Now; var result = _memberRegistration.UpdateMember(automember); if (result > 0) { return(Ok()); } return(BadRequest()); } return(Conflict()); } return(BadRequest()); }