Example #1
0
        public IActionResult Post([FromBody] List <RetrievalDetailsAPI> retrievalDetailsList)
        {
            List <RetrievalDetailsAPI> list = retrievalDetailsList;
            bool status = true;

            foreach (RetrievalDetailsAPI rd in list)
            {
                int rtDetailsId  = rd.RetrievalDetailsId;
                int actualRetQty = rd.ActualRetrievedQty;

                if (actualRetQty > 0)
                {
                    RetrievalDetails rtd = rs.FindRetDetailsByRetDetailsId(rtDetailsId);
                    rs.UpdateRetrievedQty(rtd, actualRetQty);
                }
                else
                {
                    status = false;
                }
            }
            if (status)
            {
                Retrieval retrieval = rs.FindRetById(retrievalDetailsList.First().RetrievalId);
                rs.UpdateRetStatus(retrieval);
                return(Ok(retrievalDetailsList));
            }
            else
            {
                return(NotFound());
            }
        }
 public void CreateRetrievalDetails(int retId, Dictionary <string, int> retrievList)
 {
     foreach (var r in retrievList)
     {
         RetrievalDetails rd = new RetrievalDetails();
         rd.RetrievalId     = retId;
         rd.InventoryItem   = adProjContext.InventoryItems.SingleOrDefault(x => x.Id == r.Key);
         rd.InventoryItemId = r.Key;
         rd.QtyNeeded       = r.Value;
         adProjContext.Add(rd);
     }
     adProjContext.SaveChanges();
 }
        public RetrievalDetails FindRetDetailsByRetDetailsId(int retdetId)
        {
            RetrievalDetails retdetails = adProjContext.RetrievalDetails.Where(x => x.Id == retdetId).FirstOrDefault();

            return(retdetails);
        }
 public void UpdateRetrievedQty(RetrievalDetails rtDetails, int qty)
 {
     rtDetails.QtyRetrieved = qty;
     adProjContext.SaveChanges();
 }