Ejemplo n.º 1
0
        public ActionResult Create(PurchaseRequestLineItem prli)
        {
            prli.DateCreated = DateTime.UtcNow;
            prli.UpdateTime();
            PurchaseRequestLineItem newPRLI = db.PurchaseRequestLineItems.Add(prli);

            if (newPRLI == null)
            {
                return(Failure("Unable to create new product."));
            }

            int newid = newPRLI.Id;
            int id    = newPRLI.PurchaseRequestID;

            if (!Save())
            {
                return(BadSaveResult());
            }

            UpdateTotalForPurchaseRequest(id);

            if (!Save())
            {
                return(BadSaveResult());
            }
            return(Success("New Purchase Request line item created."));
        }
Ejemplo n.º 2
0
        public ActionResult Update(PurchaseRequestLineItem prli)
        {
            PurchaseRequestLineItem oldPRLI = db.PurchaseRequestLineItems.Find(prli.Id);

            if (prli == null)
            {
                return(Failure("Unable to find this Purchase Request line item ID"));
            }

            int id = oldPRLI.ProductID;

            oldPRLI.Copy(prli);
            oldPRLI.UpdateTime();

            if (!Save())
            {
                return(BadSaveResult());
            }

            UpdateTotalForPurchaseRequest(id);

            if (!Save())
            {
                return(BadSaveResult());
            }

            return(Success("Succesfully changed Purchase Request line item id " + prli.Id));
        }