public async Task <IHttpActionResult> Put(int id, [FromBody] ProviderProfileOtherContactBindingModel otherContact) { var existing = await Repository.GetGraphs(x => x.Id == id).FirstOrDefaultAsync(); Mapper.Map <ProviderProfileOtherContactBindingModel, OtherContact>(otherContact, existing); existing.IsDeleted = false; await Repository.SaveAsUserAsync(UserId); var modified = Mapper.Map <OtherContactViewModel>(existing); return(Ok(modified)); }
public async Task <IHttpActionResult> PostOtherContact(int id, [FromBody] ProviderProfileOtherContactBindingModel contact) { var newContact = Mapper.Map <OtherContact>(contact); newContact.PersonId = id; Repository.AddOrUpdate(newContact); await Repository.SaveAsUserAsync(UserId); var newlyAdded = await Repository.Get(x => x.Id == newContact.Id).FirstOrDefaultAsync(); if (newlyAdded != null) { var model = Mapper.Map <OtherContactViewModel>(newlyAdded); return(Ok(model)); } else { return(InternalServerError()); } }