public async Task <IHttpActionResult> PostEntityAddress(EntityAddressDTO value) { try { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } DbContext.EntityAddresses.Add(EntityAddressTX.ReadFromDTO(new EntityAddress(), value)); await DbContext.SaveChangesAsync(); return(CreatedAtRoute("DefaultApi", new { AddressId = value.AddressId }, value)); } catch (Exception ex) { Log.Error("EntityAddress.Post: " + ex); throw; } }
public async Task <IHttpActionResult> GetEntityAddress(int addressId) { try { EntityAddressDTO found = await Task.Run(() => { return(EntityAddressTX.WriteToDTO(DbContext.EntityAddresses .AsEnumerable().FirstOrDefault(e => e.AddressId == addressId))); }); if (found == null) { return(NotFound()); } return(Ok(found)); } catch (Exception ex) { Log.Error("EntityAddress.Get: " + ex); throw; } }