public async Task <DTOactiveproductitem> Postactiveproductitem(DTOactiveproductitem newDTO)
        {
            activeproductitem newProd = EntityMapper.updateEntity(null, newDTO);

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

            return(newDTO);
        }
        public async Task <IHttpActionResult> Putactiveproductitem(int ID, DTOactiveproductitem editedDTO)
        {
            //
            activeproductitem toUpdate = db.activeproductitems.Find(ID);

            toUpdate = EntityMapper.updateEntity(toUpdate, editedDTO);
            db.Entry(toUpdate).State = EntityState.Modified;
            await db.SaveChangesAsync();

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemple #3
0
        public async Task <IHttpActionResult> setIsActiveToTrue(int activeProductID)
        {
            activeproductitem    toUpdate = (from c in db.activeproductitems where c.ActiveProductItems_ID == activeProductID select c).SingleOrDefault();
            DTOactiveproductitem dtoAct   = new DTOactiveproductitem(toUpdate);

            dtoAct.isActive          = true;
            toUpdate                 = EntityMapper.updateEntity(toUpdate, dtoAct);
            db.Entry(toUpdate).State = EntityState.Modified;
            await db.SaveChangesAsync();

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemple #4
0
        public static activeproductitem updateEntity(activeproductitem entityObjct, DTOactiveproductitem dto)
        {
            if (entityObjct == null)
            {
                entityObjct = new activeproductitem();
            }

            entityObjct.ActiveProductItems_ID      = dto.ActiveProductItems_ID;
            entityObjct.Consumer_ID                = dto.Consumer_ID;
            entityObjct.Product_ID                 = dto.Product_ID;
            entityObjct.activeProductItemPolicyNum = dto.activeProductItemPolicyNum;
            entityObjct.isActive     = dto.isActive;
            entityObjct.Accepted     = dto.Accepted;
            entityObjct.productValue = dto.productValue;
            entityObjct.duration     = dto.duration;
            entityObjct.activeProductItemStartDate  = dto.activeProductItemStartDate;
            entityObjct.transactionlocation         = dto.transactionlocation;
            entityObjct.activeProductItemEndDate    = dto.activeProductItemEndDate;
            entityObjct.PurchaseConfirmationDocPath = dto.PurchaseConfirmationDocPath;

            return(entityObjct);
        }