public ActionResult Create(PcProblem PcProblem, FormCollection formCollection) //,Guid? itemGID) //public ActionResult Create(FormCollection formCollection) { var myrole = new Class1(); var userID = User.Identity.GetUserId(); ViewBag.currentrole = myrole.a(userID); var i111 = formCollection["d1"]; var saving1 = new PcProblem { GID = Guid.NewGuid(), //MoreDetails = formCollection["d4"], MoreDetails = PcProblem.MoreDetails, username = User.Identity.Getusern(), date = System.DateTime.Now, IsSolved = false, //cat_problem_id = Int32.Parse(formCollection["d0"]), cat_problem_id = PcProblem.cat_problem_id, //lab_id = Int32.Parse(formCollection["d1"]), lab_id = PcProblem.lab_id, //NamePc = Guid.Parse(formCollection["d2"]), NamePc = PcProblem.NamePc, //itemGID = Guid.Parse(formCollection["d3"]) itemGID = PcProblem.itemGID //itemGID=new Guid(i111) }; if (ModelState.IsValid) { var saving = new PcProblem { GID = Guid.NewGuid(), //MoreDetails = formCollection["d4"], MoreDetails = PcProblem.MoreDetails, username = User.Identity.Getusern(), date = System.DateTime.Now, IsSolved = false, //cat_problem_id = Int32.Parse(formCollection["d0"]), cat_problem_id = PcProblem.cat_problem_id, //lab_id = Int32.Parse(formCollection["d1"]), lab_id = PcProblem.lab_id, //NamePc = Guid.Parse(formCollection["d2"]), NamePc = PcProblem.NamePc, //itemGID = Guid.Parse(formCollection["d3"]) itemGID = PcProblem.itemGID //itemGID = new Guid(i111) }; db.PcProblems.Add(saving); db.SaveChanges(); TempData["Success"] = "Υour request has been successfully submitted. We thoroughly check it to resolve it!"; return(RedirectToAction("Index")); } else { TempData["Op"] = "Fill all the textboxes in order to submit a problem"; return(View("Create")); } }
public ActionResult Solved(Guid id) { var saving = new PcProblem { GID = id, MoreDetails = (from R in db.PcProblems where R.GID == id select R.MoreDetails).FirstOrDefault(), username = (from R in db.PcProblems where R.GID == id select R.username).FirstOrDefault(), date = (from R in db.PcProblems where R.GID == id select R.date).FirstOrDefault(), IsSolved = true, cat_problem_id = (from R in db.PcProblems where R.GID == id select R.cat_problem_id).FirstOrDefault(), NamePc = (from R in db.PcProblems where R.GID == id select R.NamePc).FirstOrDefault(), lab_id = (from R in db.PcProblems where R.GID == id select R.lab_id).FirstOrDefault(), itemGID = (from R in db.PcProblems where R.GID == id select R.itemGID).FirstOrDefault() }; PcProblem PcProblem = db.PcProblems.Find(id); db.PcProblems.Remove(PcProblem); db.SaveChanges(); db.PcProblems.Add(saving); db.SaveChanges(); return(RedirectToAction("Index")); }