public async Task <DTOvouchertype> Postvouchertype(DTOvouchertype newDTO) { vouchertype newProd = EntityMapper.updateEntity(null, newDTO); db.vouchertypes.Add(newProd); await db.SaveChangesAsync(); return(newDTO); }
public async Task <IHttpActionResult> Putvouchertype(int ID, DTOvouchertype editedDTO) { vouchertype toUpdate = db.vouchertypes.Find(ID); toUpdate = EntityMapper.updateEntity(toUpdate, editedDTO); db.Entry(toUpdate).State = EntityState.Modified; await db.SaveChangesAsync(); return(StatusCode(HttpStatusCode.NoContent)); }
public static vouchertype updateEntity(vouchertype entityObjct, DTOvouchertype dto) { if (entityObjct == null) { entityObjct = new vouchertype(); } entityObjct.VoucherType_ID = dto.VoucherType_ID; entityObjct.voucherTypeDescription = dto.voucherTypeDescription; return(entityObjct); }