Ejemplo n.º 1
0
        public IHttpActionResult PutWork_Orders(int id, Work_Orders work_Orders)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != work_Orders.workOrderID)
            {
                return(BadRequest());
            }

            db.Entry(work_Orders).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!Work_OrdersExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Ejemplo n.º 2
0
        public ActionResult DeleteConfirmed(int id)
        {
            Work_Orders work_Orders = db.Work_Orders.Find(id);

            db.Work_Orders.Remove(work_Orders);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 3
0
 public ActionResult Edit([Bind(Include = "Work_Order_ID,Status_ID,Customer_ID,Instructions,Rush,Conditional_Tests,Price_Quote,Discount,Total_Cost")] Work_Orders work_Orders)
 {
     if (ModelState.IsValid)
     {
         db.Entry(work_Orders).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(work_Orders));
 }
Ejemplo n.º 4
0
        public IHttpActionResult GetWork_Orders(int id)
        {
            Work_Orders work_Orders = db.Work_Orders.Find(id);

            if (work_Orders == null)
            {
                return(NotFound());
            }

            return(Ok(work_Orders));
        }
Ejemplo n.º 5
0
 public ActionResult Edit([Bind(Include = "Work_Order_ID,Status_ID,Customer_ID,Instructions,Rush,Conditional_Tests,Price_Quote,Discount,Total_Cost")] Work_Orders work_Orders)
 {
     work_Orders.Status_ID   = 1; //reset status after changes
     work_Orders.Customer_ID = db.Customers.FirstOrDefault(p => p.Email == User.Identity.Name).Customer_ID;
     if (ModelState.IsValid)
     {
         db.Entry(work_Orders).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index", "Work_Orders"));
     }
     return(View(work_Orders));
 }
Ejemplo n.º 6
0
        public IHttpActionResult PostWork_Orders(Work_Orders work_Orders)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Work_Orders.Add(work_Orders);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = work_Orders.workOrderID }, work_Orders));
        }
Ejemplo n.º 7
0
        public ActionResult EditWork_Orders([Bind(Include = "Work_Order_ID,Status_ID,Customer_ID,Instructions,Rush,Price_Quote,Discount,Total_Cost")] Work_Orders work_Orders)
        {
            //work_Orders.Status_ID = 1; //reset status after changes
            // work_Orders.Customer_ID = db.Work_Orders.Find(work_Orders.Work_Order_ID).Customer_ID;

            if (ModelState.IsValid)
            {
                db.Entry(work_Orders).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(View(work_Orders));
        }
Ejemplo n.º 8
0
        // GET: Work_Orders/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Work_Orders work_Orders = db.Work_Orders.Find(id);

            if (work_Orders == null)
            {
                return(HttpNotFound());
            }
            return(View(work_Orders));
        }
Ejemplo n.º 9
0
        public ActionResult Create([Bind(Include = "Work_Order_ID,Status_ID,Customer_ID,Instructions,Rush,Conditional_Tests,Price_Quote,Discount,Total_Cost")] Work_Orders work_Orders)
        {
            if (ModelState.IsValid)
            {
                Customers cust = db.Customers.FirstOrDefault(p => p.Email == User.Identity.Name);// get customer

                if (work_Orders.Instructions == null)
                {
                    work_Orders.Instructions = "";
                }
                work_Orders.Customer_ID = cust.Customer_ID;
                work_Orders.Discount    = cust.Qualify_Discount;
                work_Orders.Price_Quote = -5;
                work_Orders.Total_Cost  = -5;
                work_Orders.Status_ID   = 1;// should start by default as like order sent or something at the begining

                db.Work_Orders.Add(work_Orders);
                db.SaveChanges();

                //send confirmation of work order via email

                var senderEmail   = new MailAddress("*****@*****.**", "NorthWest Labs");
                var receiverEmail = new MailAddress(cust.Email, "Receiver");
                var password      = "******";
                var body          = "Thank you for submitting your work order! Please attach the following ID to the solution you send: " + work_Orders.Work_Order_ID + ". " +
                                    "You will receive a confirmation when your compound has been received. A price quote will be included.";
                var smtp = new SmtpClient
                {
                    Host                  = "smtp.gmail.com",
                    Port                  = 587,
                    EnableSsl             = true,
                    DeliveryMethod        = SmtpDeliveryMethod.Network,
                    UseDefaultCredentials = false,
                    Credentials           = new NetworkCredential(senderEmail.Address, password)
                };
                using (var mess = new MailMessage(senderEmail, receiverEmail)
                {
                    Subject = "From Northwest Labs Singapore",
                    Body = body + "\n\n" + "Our email if you have any questions: " + senderEmail.Address + "\n"
                })
                {
                    smtp.Send(mess);
                }

                // this will then take you to which assays you want to add.
                return(RedirectToAction("Index", "Assays", new { id = work_Orders.Work_Order_ID }));
            }

            return(View(work_Orders));
        }
Ejemplo n.º 10
0
        public IHttpActionResult DeleteWork_Orders(int id)
        {
            Work_Orders work_Orders = db.Work_Orders.Find(id);

            if (work_Orders == null)
            {
                return(NotFound());
            }

            db.Work_Orders.Remove(work_Orders);
            db.SaveChanges();

            return(Ok(work_Orders));
        }
Ejemplo n.º 11
0
        //inside here will be materials edits and stuff.
        public ActionResult EditWork_Orders(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Work_Orders work_Orders = db.Work_Orders.Find(id);

            ViewBag.Rush     = work_Orders.Rush;
            ViewBag.Discount = work_Orders.Discount;
            if (work_Orders == null)
            {
                return(HttpNotFound());
            }
            return(View(work_Orders));
        }
Ejemplo n.º 12
0
        // GET: Work_Orders/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Work_Orders work_Orders = db.Work_Orders.Find(id);

            if (work_Orders == null)
            {
                return(HttpNotFound());
            }

            Status myStatus = db.Statuses.FirstOrDefault(o => o.Status_ID == work_Orders.Status_ID);

            ViewBag.myStatus = myStatus.Status_Desc;

            return(View(work_Orders));
        }