// POST: api/Payor /// <summary> /// Method to insert/save payor record /// </summary> /// <param name="payor">payor records to be updated</param> /// <returns></returns> public IHttpActionResult Put(PayorDTO payor) { if (true)//TODO: replace this with validation logic ModelState.IsValid { var searchedPayor = _payorService.FindBy(t => t.Id == payor.Id); if (payor == null) { return(BadRequest("Cannot update payor/payor not found")); } var toBeUpdatedRecord = Mapper.Map <Payor>(payor); _payorService.Update(toBeUpdatedRecord); //_unitOfWork.Commit(); return(Ok()); } else { return(BadRequest()); } }
/// <summary> /// Method to insert/save payor record /// </summary> /// <param name="payor">payor records to be inserted/saved</param> /// <returns></returns> public HttpResponseMessage Post(PayorDTO payorDTO) { if (true)//TODO: replace this with validation logic ModelState.IsValid { //try //{ var payor = Mapper.Map <Payor>(payorDTO); _payorService.Add(payor); //_unitOfWork.Commit(); HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created, payor); response.Headers.Location = new Uri(Url.Link("DefaultApi", new { id = payor.Id })); return(response); //} //catch (Exception ex) //{ // _unitOfWork.Rollback(); // return Request.CreateResponse(HttpStatusCode.BadRequest); //} } else { return(Request.CreateResponse(HttpStatusCode.BadRequest)); } }