public async Task <DTOlocation> Postlocation(DTOlocation newDTO) { location newProd = EntityMapper.updateEntity(null, newDTO); db.locations.Add(newProd); await db.SaveChangesAsync(); return(newDTO); }
public async Task <IHttpActionResult> Putlocation(int ID, DTOlocation editedDTO) { location toUpdate = db.locations.Find(ID); toUpdate = EntityMapper.updateEntity(toUpdate, editedDTO); db.Entry(toUpdate).State = EntityState.Modified; await db.SaveChangesAsync(); return(StatusCode(HttpStatusCode.NoContent)); }
public static location updateEntity(location entityObjct, DTOlocation dto) { if (entityObjct == null) { entityObjct = new location(); } entityObjct.Location_ID = dto.Location_ID; entityObjct.Province = dto.Province; entityObjct.City = dto.City; entityObjct.LatLng = dto.LatLng; entityObjct.PostalCode = dto.PostalCode; entityObjct.GDP = dto.GDP; entityObjct.UnemploymentRate = dto.UnemploymentRate; return(entityObjct); }