public async Task <DTOinsurancetype> Postinsurancetype(DTOinsurancetype newDTO) { insurancetype newProd = EntityMapper.updateEntity(null, newDTO); db.insurancetypes.Add(newProd); await db.SaveChangesAsync(); return(newDTO); }
public async Task <IHttpActionResult> Putinsurancetype(int ID, DTOinsurancetype editedDTO) { insurancetype toUpdate = db.insurancetypes.Find(ID); toUpdate = EntityMapper.updateEntity(toUpdate, editedDTO); db.Entry(toUpdate).State = EntityState.Modified; await db.SaveChangesAsync(); return(StatusCode(HttpStatusCode.NoContent)); }
public static insurancetype updateEntity(insurancetype entityObjct, DTOinsurancetype dto) { if (entityObjct == null) { entityObjct = new insurancetype(); } entityObjct.InsuranceType_ID = dto.InsuranceType_ID; entityObjct.insuranctTypeDescription = dto.insuranctTypeDescription; entityObjct.RequirementsForPurchase = dto.RequirementsForPurchase; return(entityObjct); }