public ActionResult CreateNode(int id)
        {
            var model = _db.LinkedListSignatureNodes.Find(id);
            LinkedListSignatureNode newNode = new LinkedListSignatureNode();

            newNode.RoutingSlipID = model.RoutingSlipID;
            if (model.NextSNode == null)
            {
                model.NextSNode = newNode;
            }
            else // middle node
            {
                model.NextSNode.PrevSNode = newNode;
                model.NextSNode           = newNode;
                newNode.PrevSNode         = model;
                newNode.NextSNode         = model.NextSNode;
            }

            Signature newSignature = new Signature();

            newSignature.RoutingSlipID = model.RoutingSlipID;
            newSignature.Status        = "N/A";
            newNode.Data = newSignature;
            _db.LinkedListSignatureNodes.Add(newNode);

            if (ModelState.IsValid)
            {
                //_db.SaveChanges();
                return(RedirectToAction("CreateSignature", new { id = newNode.ID }));
            }
            else
            {
                return(View(model));
            }
        }
        // GET: LinkedListSignatureNode/Delete/5
        public ActionResult Delete(int id)
        {
            LinkedListSignatureNode llsn = _db.LinkedListSignatureNodes.Find(id);

            if (llsn == null)
            {
                return(HttpNotFound());
            }
            return(RedirectToAction("DeleteNode", new { id = llsn.ID }));
        }
 public ActionResult CreateSignature(LinkedListSignatureNode l)
 {
     if (ModelState.IsValid)
     {
         var modelID = l.RoutingSlipID;
         return(RedirectToAction("Details", new { id = modelID }));
     }
     else
     {
         return(HttpNotFound());
     }
 }
        public ActionResult SetPrevNext(int id)
        {
            var modelA = _db.RoutingSlips.Find(id);
            var model  = _db.LinkedListSignatureNodes;
            var count  = 0;
            LinkedListSignatureNode current = new LinkedListSignatureNode();
            var queryModel = from n in model
                             where n.RoutingSlipID == modelA.RoutingSlipID
                             orderby n.ID ascending
                             select n;

            foreach (LinkedListSignatureNode l in queryModel)
            {
                if (count == 0)
                {
                    l.PrevSNode = null;
                    l.NextSNode = null;
                    current     = l;
                    count++;
                }
                else
                {
                    l.PrevSNode       = current;
                    current.NextSNode = l;
                    current           = l;
                    current.NextSNode = null;
                    count++;
                }
            }
            if (ModelState.IsValid)
            {
                _db.SaveChanges();
                //return View(queryModel); //commented out 5.5
                //return RedirectToAction("Index");
                //return RedirectToAction("SetPrevNext", model.RoutingSlipID); //model
                return(RedirectToAction("BeginEmailProc", new { id = modelA.RoutingSlipID })); //model

                //return RedirectToAction("Details", "RoutingSlip", new { id = modelA.RoutingSlipID }); //THIS 7.16
            }
            return(View(modelA));
        }
Beispiel #5
0
        public ActionResult Forward(int id)
        {
            // Change current name attribute of routing slip
            //LinkedListSignatureNode llsn = _db.LinkedListSignatureNodes.SingleOrDefault(linkedlist => linkedlist.RoutingSlipID == id && linkedlist.Data.SignatureName == currname);
            LinkedListSignature     lls  = _db.LinkedListSignatures.SingleOrDefault(link => link.RoutingSlipID == id);
            LinkedListSignatureNode llsn = _db.LinkedListSignatureNodes.SingleOrDefault(node => node.Data.SignatureName == lls.CurrentName && node.RoutingSlipID == id);

            RoutingSlip rs = _db.RoutingSlips.Find(id);

            rs.LinkedListSignature.CurrentName = llsn.NextSNode.Data.SignatureName;
            //rs.LinkedListSignature.CurrentName = llsn.NextSNode.Data.SignatureName;
            //var newCurrent = llsn.NextSNode.Data.SignatureName;
            llsn.Data.DateRouted = DateTime.Now;
            //var model = _db.RoutingSlips.Find(id);
            //model.LinkedListSignature.CurrentName = newCurrent;

            if (ModelState.IsValid)
            {
                _db.SaveChanges();
                return(RedirectToAction("Index", "RoutingSlip"));
            }
            return(View(id));
        }
        public ActionResult CreateLinkedList(int id)
        {
            var model = _db.RoutingSlips.Find(id);


            Signature Initiator = new Signature
            {
                SignatureName = model.RequestingEmployee,
                DateRouted    = model.DateSubmitted,
                Status        = "Originator",
                RoutingSlipID = id,
            };

            LinkedListSignature lls = new LinkedListSignature
            {
                RoutingSlipID = id
            };
            LinkedListSignatureNode headll = new LinkedListSignatureNode
            {
                Data          = Initiator,
                RoutingSlipID = id
            };
            List <LinkedListSignatureNode> llsn = new List <LinkedListSignatureNode>
            {
                headll
            };
            LinkedListSignatureNode current = new LinkedListSignatureNode();

            current = headll;

            //var count = 2;
            if (model.ForwardTo.Contains(","))
            {
                model.ForwardTo = model.ForwardTo.Substring(0, model.ForwardTo.Length - 1);
                string[]      namesArray = model.ForwardTo.Split(',');
                List <string> namesList  = new List <string>(namesArray.Length);

                for (var i = 0; i < namesArray.Length; i++)
                {
                    namesArray[i] = namesArray[i].Trim();

                    Signature s = new Signature
                    {
                        SignatureName = namesArray[i],
                        Status        = "N/A",
                        RoutingSlipID = id,
                        //        //SignatureID = count++,
                    };
                    LinkedListSignatureNode sNode = new LinkedListSignatureNode
                    {
                        Data          = s,
                        RoutingSlipID = id
                    };
                    if (i == 0)
                    {
                        lls.CurrentName = sNode.Data.SignatureName;
                    }

                    llsn.Add(sNode);
                }
            }
            else
            {
                Signature s = new Signature
                {
                    SignatureName = model.ForwardTo,
                    Status        = "N/A",
                    RoutingSlipID = id,
                };
                LinkedListSignatureNode sNode = new LinkedListSignatureNode
                {
                    Data          = s,
                    RoutingSlipID = id
                };


                //current.Next = sNode;
                llsn.Add(current);
                //sNode.Prev = current;

                current = sNode;
                llsn.Add(sNode);
                lls.CurrentName = sNode.Data.SignatureName;
            }

            lls.LLSNodes = llsn;
            model.LinkedListSignature = lls;

            if (ModelState.IsValid)
            {
                _db.SaveChanges();
                return(RedirectToAction("SetPrevNext", model.RoutingSlipID)); //model
            }
            return(View(model));
        }