public IActionResult Post([FromBody] MemberRegistrationViewModel member) { try { if (ModelState.IsValid) { if (!_memberRegistration.CheckNameExits(member.MemberFName, member.MemberLName, member.MemberMName)) { var userId = this.User.FindFirstValue(ClaimTypes.Name); var automember = AutoMapper.Mapper.Map <MemberRegistration>(member); automember.JoiningDate = DateTime.Now; automember.CreatedBy = Convert.ToInt32(userId); var result = _memberRegistration.InsertMember(automember); if (result > 0) { return(Ok()); } return(BadRequest()); } return(Conflict()); } return(BadRequest()); } catch (Exception) { throw; } }
public HttpResponseMessage Post([FromBody] MemberRegistrationViewModel member) { try { if (ModelState.IsValid) { if (!_memberRegistration.CheckNameExits(member.MemberFName, member.MemberLName, member.MemberMName)) { var userId = this.User.FindFirstValue(ClaimTypes.Name); var automember = AutoMapper.Mapper.Map <MemberRegistration>(member); automember.JoiningDate = DateTime.Now; automember.Createdby = Convert.ToInt32(userId); var result = _memberRegistration.InsertMember(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 // Staus code: 409 }; return(response); } } else { var response = new HttpResponseMessage() { StatusCode = HttpStatusCode.BadRequest // Staus code: 400 }; return(response); } } catch (Exception) { throw; } }