public async Task <IHttpActionResult> Putinsuranceproduct(int InsuranceProduct_ID, DTOinsuranceproduct insuranceproduct) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (InsuranceProduct_ID != insuranceproduct.InsuranceProduct_ID) { return(BadRequest()); } insuranceproduct toUpdate = db.insuranceproducts.Single(c => c.InsuranceProduct_ID == InsuranceProduct_ID); toUpdate = EntityMapper.updateEntity(toUpdate, insuranceproduct); db.Entry(toUpdate).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!insuranceproductExists(InsuranceProduct_ID)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public InsuranceManagerViewProducts(insuranceproduct prod) { id = prod.Product_ID; name = prod.product.productName; typeOfInsurance = prod.insurancetype.insuranctTypeDescription; icon = IDtoIcon(prod.insurancetype.InsuranceType_ID); }
public static insuranceproduct updateEntity(insuranceproduct entityObjct, DTOinsuranceproduct dto) { if (entityObjct == null) { entityObjct = new insuranceproduct(); } entityObjct.InsuranceProduct_ID = dto.InsuranceProduct_ID; entityObjct.ProductProvider_ID = dto.ProductProvider_ID; entityObjct.InsuranceType_ID = dto.InsuranceType_ID; entityObjct.Product_ID = dto.Product_ID; entityObjct.ipCoverAmount = dto.ipCoverAmount; entityObjct.ipUnitCost = dto.ipUnitCost; entityObjct.ipUnitType = dto.ipUnitType; entityObjct.ipMinimunNoOfUnits = dto.ipMinimunNoOfUnits; entityObjct.ipClaimInfoPath = dto.ipClaimInfoPath; entityObjct.claimTimeframe = dto.claimTimeframe; entityObjct.policyNumberApiLink = dto.policyNumberApiLink; entityObjct.ApiKey = dto.ApiKey; entityObjct.claimContactNo = dto.claimContactNo; entityObjct.claimFormPath = dto.claimFormPath; entityObjct.claimtemplate_ID = dto.claimtemplate_ID; return(entityObjct); }
public async Task <DTOinsuranceproduct> Postinsuranceproduct(DTOinsuranceproduct newDTO) { insuranceproduct newProd = EntityMapper.updateEntity(null, newDTO); db.insuranceproducts.Add(newProd); await db.SaveChangesAsync(); return(newDTO); }
public DTOcatalogInsuranceProduct(insuranceproduct prod) { productID = prod.Product_ID; productName = prod.product.productName; productDescription = prod.product.productDescription; coverAmount = prod.ipCoverAmount; unitCost = prod.ipUnitCost; unitType = prod.unittype.UnitTypeDescription; minUnits = prod.ipMinimunNoOfUnits; }
public async Task <IHttpActionResult> Putinsuranceproduct(int ID, DTOinsuranceproduct editedDTO) { insuranceproduct toUpdate = db.insuranceproducts.Find(ID); toUpdate = EntityMapper.updateEntity(toUpdate, editedDTO); db.Entry(toUpdate).State = EntityState.Modified; await db.SaveChangesAsync(); return(StatusCode(HttpStatusCode.NoContent)); }
public DTOinsuranceproduct GetInsuranceProduct(int productId) { insuranceproduct p = db.insuranceproducts.Where(c => c.Product_ID == productId).SingleOrDefault(); DTOinsuranceproduct toReturn = new DTOinsuranceproduct(p); if (toReturn == null) { return(null); } return(toReturn); }
public InsuranceProductMobileDTO(insuranceproduct p) { product prod = p.product; id = p.Product_ID; name = prod.productName; description = prod.productDescription; cost = (Decimal)p.ipUnitCost; insuranceTypeID = p.InsuranceType_ID; typeName = p.insurancetype.insuranctTypeDescription; unitType = p.unittype.UnitTypeDescription; }
//Helper method for getClaimTemplateFromProductID public int getClaimTemplateID(int productID) { //get the claimTemplateID for the specified product. int templateID = 0; insuranceproduct insProd = (from i in db.insuranceproducts where i.Product_ID == productID select i).SingleOrDefault(); if (insProd.claimtemplate_ID != null) { templateID = insProd.claimtemplate_ID.Value; } return(templateID); }
public async Task <IHttpActionResult> Getinsuranceproduct(int ProductProviderID, int productID) { insuranceproduct prod = await db.insuranceproducts.SingleAsync(c => c.ProductProvider_ID == ProductProviderID && c.Product_ID == productID); DTOinsuranceproduct insuranceproduct = new DTOinsuranceproduct(prod); if (insuranceproduct == null) { return(NotFound()); } return(Ok(insuranceproduct)); }
public async Task <IHttpActionResult> Postinsuranceproduct(DTOinsuranceproduct insuranceproduct) { //insure json conversion is correct if (!ModelState.IsValid) { return(BadRequest(ModelState)); } insuranceproduct newProd = EntityMapper.updateEntity(null, insuranceproduct); db.insuranceproducts.Add(newProd); await db.SaveChangesAsync(); return(CreatedAtRoute("DefaultApi", new { id = newProd.InsuranceProduct_ID }, insuranceproduct)); }
private string getProductUnitType(int ProductID)//called inside redeem method { insuranceproduct insProd = (from c in db.insuranceproducts where c.Product_ID == ProductID select c).SingleOrDefault(); return(insProd.unittype.UnitTypeDescription); }