Exemplo n.º 1
0
 /// <summary>
 /// Method to insert/save payor record
 /// </summary>
 /// <param name="addressDto">address records to be inserted/saved</param>
 /// <returns></returns>
 public HttpResponseMessage Post(AddressDTO addressDto)
 {
     if (true)//TODO: replace this with validation logic ModelState.IsValid
     {
         var record = Mapper.Map<Address>(addressDto);
         _addressService.Add(record);
         HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created, addressDto);
         response.Headers.Location = new Uri(Url.Link("DefaultApi", new { id = addressDto.Id }));
         return response;
     }
     else
     {
         return Request.CreateResponse(HttpStatusCode.BadRequest);
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// Method to insert/save Address
 /// </summary>
 /// <param name="address">address to be updated</param>
 /// <returns></returns>
 public IHttpActionResult Put(AddressDTO address)
 {
     if (true)//TODO: replace this with validation logic ModelState.IsValid
     {
         var searchedPayor = _addressService.FindBy(t => t.Id == address.Id);
         if (address == null)
         {
             return BadRequest("Cannot update payor/payor not found");
         }
         var toBeUpdatedRecord = Mapper.Map<Address>(address);
         _addressService.Update(toBeUpdatedRecord);
         return Ok();
     }
     else
     {
         return BadRequest();
     }
 }