Exemplo n.º 1
0
        public async Task <ActionResult> Backorder(int?id)
        {
            if (id == null)
            {
                return(View("error", new string[] { "HTTP Error 400. Bad Request, please check the url and try again." }));
            }

            UrnForm urn;

            using (UrnDbContext db = new UrnDbContext())
            {
                urn = await db.UrnForms.FirstOrDefaultAsync(u => u.Id == id);

                if (TryUpdateModel(urn))
                {
                    urn.Status             = "Backorder";
                    urn.ReasonForBackorder = Request["ReasonForBackorder"];
                    urn.BackorderDate      = DateTime.Now;
                    db.Entry(urn).State    = EntityState.Modified;
                }
                TempData["message"] = $"Work order { urn.RrNumber } successfully sent to backorder";
                await db.SaveChangesAsync();
            }

            return(RedirectToAction("index", "home", null));
        }
Exemplo n.º 2
0
        public async Task <ActionResult> Complete(int?id)
        {
            if (id == null)
            {
                return(View("error", new string[] { "HTTP Error 400. Bad Request, please check the url and try again." }));
            }

            UrnForm urnForm;

            using (UrnDbContext db = new UrnDbContext())
            {
                urnForm = await db.UrnForms.FirstOrDefaultAsync(urn => urn.Id == id);

                if (TryUpdateModel(urnForm))
                {
                    urnForm.Status        = "Completed";
                    urnForm.TimeCompleted = DateTime.Now;

                    if (Request["raNumber"] != string.Empty || Request["serial"] != string.Empty)
                    {
                        urnForm.RaNumber     = Request["raNumber"];
                        urnForm.SerialNumber = Request["serial"];
                    }

                    urnForm.CompletedBy     = HttpContext.User.Identity.Name;
                    db.Entry(urnForm).State = EntityState.Modified;
                }

                TempData["message"] = $"Work order { urnForm.RrNumber } has been successfully completed.";
                await db.SaveChangesAsync();
            }

            return(RedirectToAction("index", "home", null));
        }
Exemplo n.º 3
0
        public async Task <ActionResult> Queue(int?id)
        {
            if (id == null)
            {
                return(View("error", new string[] { "HTTP Error 400. Bad Request, please check the url and try again." }));
            }

            UrnForm urnForm;

            using (UrnDbContext db = new UrnDbContext())
            {
                urnForm = await db.UrnForms.FirstOrDefaultAsync(urn => urn.Id == id);

                if (TryUpdateModel(urnForm))
                {
                    urnForm.Status          = "Queued";
                    db.Entry(urnForm).State = EntityState.Modified;
                }

                TempData["message"] = $"Work order { urnForm.RrNumber } has succesfully been queued.";
                await db.SaveChangesAsync();
            }

            return(RedirectToAction("index", "home", null));
        }
Exemplo n.º 4
0
        public async Task <ActionResult> UpdateWo(int?id)
        {
            UrnForm workOrder;

            using (UrnDbContext _db = new UrnDbContext())
            {
                workOrder = await _db.UrnForms.FirstOrDefaultAsync(wo => wo.Id == id);

                if (ModelState.IsValid)
                {
                    try
                    {
                        if (TryUpdateModel(workOrder))
                        {
                            _db.Entry(workOrder).State = EntityState.Modified;
                            await _db.SaveChangesAsync();

                            TempData["message"] = $"Work order { workOrder.RrNumber } successfully updated.";
                            return(RedirectToAction("index", "queue", null));
                        }
                    }
                    catch (DataException ex)
                    {
                        ModelState.AddModelError("", ex.Message);
                    }
                }
            }
            return(View(workOrder));
        }
Exemplo n.º 5
0
        public async Task <ActionResult> Ship(int?id)
        {
            if (id == null)
            {
                return(View("error", new string[] { "HTTP Error 400. Bad Request, please check the url and try again." }));
            }

            UrnForm urnForm;

            using (UrnDbContext db = new UrnDbContext())
            {
                urnForm = await db.UrnForms.FirstOrDefaultAsync(urn => urn.Id == id);

                if (TryUpdateModel(urnForm))
                {
                    urnForm.Status                = "Shipped";
                    urnForm.TimeShipped           = DateTime.Now;
                    urnForm.ShippedBy             = HttpContext.User.Identity.Name;
                    urnForm.ReasonForIncompletion = "";

                    if (Request["issueResolution"] != string.Empty)
                    {
                        urnForm.ResolutionStatus = Request["issueResolution"];
                    }

                    db.Entry(urnForm).State = EntityState.Modified;
                }

                await db.SaveChangesAsync();
            }

            TempData["message"] = $"Work order { urnForm.RrNumber } has successfully been shipped.";

            return(RedirectToAction("index", "completed", null));
        }
Exemplo n.º 6
0
        public async Task <ActionResult> Undo(int?id)
        {
            if (id == null)
            {
                return(View("error", new string[] { "HTTP Error 400. Bad Request, please check the url and try again." }));
            }

            UrnForm urnForm;

            using (UrnDbContext db = new UrnDbContext())
            {
                urnForm = await db.UrnForms.FirstOrDefaultAsync(urn => urn.Id == id);

                if (TryUpdateModel(urnForm))
                {
                    urnForm.Status = "Incomplete";
                    urnForm.ReasonForIncompletion = Request["ReasonForIncompletion"];
                    db.Entry(urnForm).State       = EntityState.Modified;
                    await db.SaveChangesAsync();
                }
            }

            TempData["error"] = $"Work order { urnForm.RrNumber } has been marked as not complete.";

            return(RedirectToAction("index", "home", null));
        }