} // eo MakePullOrders --------------------------------------------------------------------

        public void SavePullHdr(PullHdr pullHdr) // ----------------------------------------------
        {
            //SaveChanges is a method of DbContext class inherited by ApplicationDbContext class
            // located in the Models folder of the base program
            // if PullHdrId = 0 then Add a new order, otherwise save changes
            context.AttachRange(pullHdr.PullItems);
            if (pullHdr.PullHdrId == 0)
            {
                context.PullHdrs.Add(pullHdr);
            }
            else
            {
                // see p308 for explanation
                PullHdr dbEntry = context.PullHdrs.FirstOrDefault(ph => ph.PullHdrId == pullHdr.PullHdrId);
                if (dbEntry != null)
                {
                    dbEntry.PullHdrId   = pullHdr.PullHdrId;
                    dbEntry.Status      = pullHdr.Status;
                    dbEntry.LocationId  = pullHdr.LocationId;
                    dbEntry.PullDate    = pullHdr.PullDate;
                    dbEntry.Destination = pullHdr.Destination;
                    dbEntry.Requester   = pullHdr.Requester;
                    dbEntry.ReqPhone    = pullHdr.ReqPhone;
                    dbEntry.ReqEmail    = pullHdr.ReqEmail;
                    dbEntry.Comment     = pullHdr.Comment;
                }
            }
            context.SaveChanges();
        } // eo SavePullHdr method ----------------------------------------------------------------
Esempio n. 2
0
 public PullDisplayViewModel(PullHdr ph, Dictionary <string, string> keyValuePairs)
 {
     PHdr  = ph;
     CIKVP = keyValuePairs;
 }