public ActionResult DeleteConfirmed(int id)
        {
            ToolTorepair toolTorepair = db.ToolsToRepair.Find(id);

            db.ToolsToRepair.Remove(toolTorepair);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit([Bind(Include = "ToolToRepairId,Type,Manufacturer,Issue,Result,TechnicianId,RepairCaseIdd")] ToolTorepair toolTorepair)
 {
     if (ModelState.IsValid)
     {
         db.Entry(toolTorepair).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.RepairCaseIdd = new SelectList(db.RepairCases, "RepairCaseId", "RepairCaseId", toolTorepair.RepairCaseIdd);
     ViewBag.TechnicianId  = new SelectList(db.Technicians, "TechnicianId", "FirstName", toolTorepair.TechnicianId);
     return(View(toolTorepair));
 }
        // GET: ToolTorepair/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ToolTorepair toolTorepair = db.ToolsToRepair.Find(id);

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

            if (toolTorepair == null)
            {
                return(HttpNotFound());
            }
            ViewBag.RepairCaseIdd = new SelectList(db.RepairCases, "RepairCaseId", "RepairCaseId", toolTorepair.RepairCaseIdd);
            ViewBag.TechnicianId  = new SelectList(db.Technicians, "TechnicianId", "FirstName", toolTorepair.TechnicianId);
            return(View(toolTorepair));
        }
        public ActionResult AddNewTool(ToolTorepair newTool, FormCollection form)
        {
            int        id = Convert.ToInt32(Request["MoveType"]);
            RepairCase rr = Session["NewRpCase"] as RepairCase;

            newTool.RepairCaseIdd = rr.RepairCaseId;

            string str  = form["ListItem3"].ToString();
            string str1 = form["ListItem1"].ToString();
            string str2 = form["ListItem2"].ToString();

            newTool.Type         = str;
            newTool.Issue        = str1;
            newTool.Manufacturer = str2;

            if ((str == "") || (str1 == "") || (str2 == ""))
            {
                //if (str == "")
                //{
                TempData["error1"] = "please make sure you select a tool type ";
                //}
                //if (str1 == "")
                //{
                TempData["error2"] = "please make sure you select a tool issue ,If you don't know it select other";
                //}
                //if (str2 == "")
                //{
                TempData["error3"] = "please make sure you select a tool maufacturer,If you don't know it select other ";
                //}
                if (id == 0)
                {
                    if (Session["toolsList"] == null)
                    {
                        return(RedirectToAction("AddNewTool", newTool));
                    }
                    return(RedirectToAction("Choice"));
                }
                return(RedirectToAction("AddNewTool", newTool));
            }

            string ch = "";

            //newTool.Type = str;
            //newTool.Issue = str1;
            //newTool.Manufacturer = str2;
            if (ModelState.IsValid)
            {
                tools.Add(newTool);
                if (Session["toolsList"] != null)
                {
                    List <ToolTorepair> list = Session["toolsList"] as List <ToolTorepair>;
                    list.Add(newTool);
                    Session["toolsList"] = list;
                }
                else
                {
                    Session["toolsList"] = tools;
                }



                switch (id)
                {
                case 0:
                    _db.ToolsToRepair.Add(newTool);
                    _db.SaveChanges();
                    if (tools.Count != 0)
                    {
                        ch = "Choice";
                    }
                    else
                    {
                        ch = "AddNewTool";
                    }

                    break;

                case 1:
                    _db.ToolsToRepair.Add(newTool);
                    _db.SaveChanges();
                    ch = "AddNewTool";

                    break;
                }

                return(RedirectToAction(ch));
            }
            else
            {
                return(View(newTool));
            }
        }
        public ActionResult AddNewTool()
        {
            var list = Session["toolsList"] as List <ToolTorepair>;

            RepairCase rr = Session["NewRpCase"] as RepairCase;

            ViewBag.error1 = TempData["error1"] as string;
            ViewBag.error2 = TempData["error2"] as string;
            ViewBag.error3 = TempData["error3"] as string;
            IEnumerable <SelectListItem> ObjItem = new List <SelectListItem>()
            {
                new SelectListItem {
                    Text = "Select", Value = "", Selected = true
                },
                new SelectListItem {
                    Text = "Battery", Value = "Battery"
                },
                new SelectListItem {
                    Text = "Mouse", Value = "Mouse"
                },
                new SelectListItem {
                    Text = "Keyboard", Value = "Keyboard"
                },
                new SelectListItem {
                    Text = "Tower", Value = "Tower"
                },
                new SelectListItem {
                    Text = "Power Cord", Value = "Power Cord"
                },
                new SelectListItem {
                    Text = "Power Supply", Value = "Power Supply"
                },
                new SelectListItem {
                    Text = "Laptop", Value = "Laptop"
                },
                new SelectListItem {
                    Text = "Other", Value = "Other"
                },
            };

            IEnumerable <SelectListItem> ObjItem1 = new List <SelectListItem>()
            {
                new SelectListItem {
                    Text = "Select", Value = "", Selected = true
                },
                new SelectListItem {
                    Text = "Black/Blue Screen", Value = "Black/Blue Screen"
                },
                new SelectListItem {
                    Text = "May Have a Virus", Value = "May Have a Virus"
                },
                new SelectListItem {
                    Text = "Won't Turn On", Value = "Won't Turn On"
                },
                new SelectListItem {
                    Text = "Install Software", Value = "Install Software"
                },
                new SelectListItem {
                    Text = "Repair Screen", Value = "Repair Screen"
                },
                new SelectListItem {
                    Text = "Repalce Hardware", Value = "Repalce Hardware"
                },
                new SelectListItem {
                    Text = "Remove Malware", Value = "Remove Malware"
                },
                new SelectListItem {
                    Text = "Dust Cleaning", Value = "Dust Cleaning"
                },
                new SelectListItem {
                    Text = "Other", Value = "Other"
                },
            };

            IEnumerable <SelectListItem> ObjItem2 = new List <SelectListItem>()
            {
                new SelectListItem {
                    Text = "Select", Value = "", Selected = true
                },
                new SelectListItem {
                    Text = "Dell", Value = "Dell"
                },
                new SelectListItem {
                    Text = "Mac", Value = "Mac"
                },
                new SelectListItem {
                    Text = "Toshiba", Value = "Toshiba"
                },
                new SelectListItem {
                    Text = "Acer", Value = "Acer"
                },
                new SelectListItem {
                    Text = "Lenovo", Value = "Lenovo"
                },
                new SelectListItem {
                    Text = "HP", Value = "HP"
                },
                new SelectListItem {
                    Text = "Sony", Value = "Sony"
                },
                new SelectListItem {
                    Text = "Fujistu", Value = "Fujistu"
                },
                new SelectListItem {
                    Text = "Asus", Value = "Asus"
                },
                new SelectListItem {
                    Text = "Samsung", Value = "Samsung"
                },
                new SelectListItem {
                    Text = "Other", Value = "Other"
                },
            };

            ViewBag.ListItem3 = ObjItem;
            ViewBag.ListItem1 = ObjItem1;
            ViewBag.ListItem2 = ObjItem2;
            ToolTorepair tt = new ToolTorepair();

            return(View(tt));
        }