public string UpdateRetrieval(WCFRetrievalForm wcfr)
        {
            try
            {
                List <RetrieveForm> list = (List <RetrieveForm>)HttpContext.Current.Application["retrieveForm"];
                RetrieveForm        rf   = list.Where(x => x.ItemCode == wcfr.ItemCode).First();

                Stationery item = stationeryService.FindStationeryByItemCode(wcfr.ItemCode);
                if (wcfr.QtyRetrieved.Value > item.stockQty)
                {
                    return("Value of Retrieved Qty cannot exceed Stock Qty.");
                }

                if (wcfr.QtyRetrieved > rf.Qty)
                {
                    return("Value of Retrieved Qty cannot exceed requested qty.");
                }

                var index = list.FindIndex(x => x.description == wcfr.Description);
                list[index].retrieveQty = wcfr.QtyRetrieved;
                /*  list[index].Qty -= wcfr.QtyRetrieved;*/ //reduce amount that is still pending retrieval

                HttpContext.Current.Application["retrieveForm"] = list;
                return("true");
            }

            catch (Exception e)
            {
                String error = e.Message;

                return(error);
            }
        }
Beispiel #2
0
        public static WCFRetrievalForm ConvertToWCFRetrieval(RetrieveForm retrieval)
        {
            WCFRetrievalForm wcfR = new WCFRetrievalForm();

            wcfR.Description  = retrieval.description;
            wcfR.Qty          = retrieval.Qty;
            wcfR.QtyRetrieved = retrieval.retrieveQty;
            //wcfR.QtyAllocated = retrieval.allocatedQty;
            wcfR.ItemCode = retrieval.ItemCode;
            //add location to WCFRetrievalForm object
            StationeryModel entity = new StationeryModel();

            wcfR.Location = entity.Stationeries.Where(x => x.description == retrieval.description).First().location;


            return(wcfR);
        }
        public WCFRetrievalForm GetRetrievalForm(string itemCode)
        {
            List <RetrieveForm> list = new List <RetrieveForm>();

            if (HttpContext.Current.Application["retrieveForm"] != null)
            {
                list = (List <RetrieveForm>)HttpContext.Current.Application["retrieveForm"];
            }
            else
            {
                //can be assumed no items have been retrieved yet since there is no retrieval list generated
            }

            WCFRetrievalForm item = WCFModelConvertUtility.ConvertToWCFRetrieval(list.Where(x => x.ItemCode == itemCode).First());

            return(item);
        }