コード例 #1
0
        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));
        }
コード例 #2
0
 public InsuranceManagerViewProducts(insuranceproduct prod)
 {
     id              = prod.Product_ID;
     name            = prod.product.productName;
     typeOfInsurance = prod.insurancetype.insuranctTypeDescription;
     icon            = IDtoIcon(prod.insurancetype.InsuranceType_ID);
 }
コード例 #3
0
ファイル: EntityMapper.cs プロジェクト: Mvrk94/TheNanoFinApi
        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);
        }
コード例 #4
0
        public async Task <DTOinsuranceproduct> Postinsuranceproduct(DTOinsuranceproduct newDTO)
        {
            insuranceproduct newProd = EntityMapper.updateEntity(null, newDTO);

            db.insuranceproducts.Add(newProd);
            await db.SaveChangesAsync();

            return(newDTO);
        }
コード例 #5
0
 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;
 }
コード例 #6
0
        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));
        }
コード例 #7
0
        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);
        }
コード例 #8
0
ファイル: ProductDTO.cs プロジェクト: Mvrk94/TheNanoFinApi
        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;
        }
コード例 #9
0
        //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);
        }
コード例 #10
0
        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));
        }
コード例 #11
0
        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));
        }
コード例 #12
0
        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);
        }