public ActionResult Create([Bind(Include = "Id,RequestId,TestId,TestTypeId,SelectedTest")] TestInRequest testInRequest)
        {
            if (ModelState.IsValid)
            {
                var manager     = new UserManager <ApplicationUser>(new Microsoft.AspNet.Identity.EntityFramework.UserStore <ApplicationUser>(new ApplicationDbContext()));
                var currentUser = manager.FindById(User.Identity.GetUserId());
                //barcodecs objbar = new barcodecs();

                if (currentUser != null)
                {
                    testInRequest.createdBy = currentUser.UserName;
                }
                else
                {
                    testInRequest.createdBy = User.Identity.Name;
                }

                testInRequest.createdDate = DateTime.Now;


                db.TestInRequest.Add(testInRequest);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.RequestId = new SelectList(db.Request, "ID", "ID", testInRequest.RequestId);
            ViewBag.TestId    = new SelectList(db.Test, "Id", "Name", testInRequest.TestId);
            //ViewBag.TestTypeId = new SelectList(db.TestType, "Id", "Name", testInRequest.TestTypeId);
            return(View(testInRequest));
        }
        public ActionResult DeleteConfirmed(int id)
        {
            TestInRequest testInRequest = db.TestInRequest.Find(id);

            db.TestInRequest.Remove(testInRequest);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        // GET: TestInRequest/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            TestInRequest testInRequest = db.TestInRequest.Find(id);

            if (testInRequest == null)
            {
                return(HttpNotFound());
            }
            return(View(testInRequest));
        }
        // GET: TestInRequest/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            TestInRequest testInRequest = db.TestInRequest.Find(id);

            if (testInRequest == null)
            {
                return(HttpNotFound());
            }
            ViewBag.RequestId = new SelectList(db.Request, "ID", "ID", testInRequest.RequestId);
            ViewBag.TestId    = new SelectList(db.Test, "Id", "Name", testInRequest.TestId);
            // ViewBag.TestTypeId = new SelectList(db.TestType, "Id", "Name", testInRequest.TestTypeId);
            return(View(testInRequest));
        }
Esempio n. 5
0
        //
        // GET: /Scanner/

        public ActionResult Index(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            TestInRequest testInRequest = db.TestInRequest.Find(id);

            testInRequest.Status = ACTIVITYSTATUS.InProcess.ToString();
            db.SaveChanges();

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

            return(View());
        }
Esempio n. 6
0
        public ActionResult Index(List <TestCheck> list)
        {
            //save this list to table tracking selected items. A row should look like:
            //id  -  listitemtosave(Testelected)(Testid) - forwhichrequestinstance(RequestId) -
            //            return View(list);

            var     testInRequest = new TestInRequest();
            var     varId         = Convert.ToInt32(TempData["reqId"]);
            decimal?cost          = 0.00m;

            //var no = db.Request.Where(x => x.ID == varId).Select(x => x.NoofSamples).FirstOrDefault();


            //var count = 1;
            foreach (TestCheck tchk in list)
            {
                if (tchk.Checked != false)
                {
                    testInRequest.TestId    = tchk.TestId;                // testInRequest.RequestId = 1; // would need to automate this later
                    testInRequest.RequestId = varId;
                    testInRequest.Status    = ACTIVITYSTATUS.NEW.ToString();
                    db.TestInRequest.Add(testInRequest);
                    db.SaveChanges();
                    //get the total cost of the test(s) checked
                    var tchk_cost = db.Test.Where(x => x.Id == tchk.TestId).Select(x => x.Cost).FirstOrDefault();
                    cost = cost + tchk_cost;
                }
            }
            var c = db.Request.Where(x => x.ID == varId).FirstOrDefault();

            c.Cost = Convert.ToDecimal(cost);
            //c.Cost = no * Convert.ToDecimal(cost);
            db.SaveChanges();

            return(RedirectToAction("Index", "TestInRequest"));
        }