public ActionResult yeucauhotro(FormCollection collection) { if (Session["dangnhap"] == null) { return(RedirectToAction("login", "home")); } if (!Equals(Session["idLevel"], 0)) { return(RedirectToAction("Error404", "home")); } Hotro model = new Hotro(); model.Ticket = LoadTicketUser(); var typeNV = collection["typeNV"]; var Tittle = collection["TittleTicket"]; var Send = collection["tText"]; if (String.IsNullOrEmpty(Tittle)) { ViewData["Err"] = "Vui lòng nhập tiêu đề"; return(View("yeucauhotro", model)); } else if (String.IsNullOrEmpty(Send) || Equals(Send, "<p><br></p>")) { ViewData["Err"] = "Vui lòng nhập nội dung"; return(View("yeucauhotro", model)); } else { try { ticket tk = new ticket(); tickets_text tktext = new tickets_text(); tk.typeTicket = Int32.Parse(typeNV); tk.DateCreate = DateTime.Parse(DateTime.Now.ToString()); tk.idtStatus = 6; tk.TittleTicket = Tittle; tk.idUserCreate = Int32.Parse(Session["dangnhap"].ToString()); tk.idUsetLastPost = Int32.Parse(Session["dangnhap"].ToString()); db.tickets.InsertOnSubmit(tk); db.SubmitChanges(); tktext.idTicket = tk.idTicket; tktext.idUser_post = Int32.Parse(Session["dangnhap"].ToString()); tktext.tText = Send; tktext.DateSent = DateTime.Parse(DateTime.Now.ToString()); db.tickets_texts.InsertOnSubmit(tktext); db.SubmitChanges(); ViewData["Success"] = "Tạo phiếu hỗ trợ thành công"; return(RedirectToAction("chitietyeucauhotro", "support", new { id = tk.idTicket })); } catch { ViewData["Err"] = "Đã xảy ra lỗi vui lòng thử lại"; return(View("yeucauhotro", model)); } } }
public ActionResult chitietyeucauhotro(FormCollection collection) { if (Session["dangnhap"] == null) { return(RedirectToAction("login", "home")); } var getid = Url.RequestContext.RouteData.Values["id"]; if (getid == null) { return(RedirectToAction("Error404", "home")); } Hotro mymodel = new Hotro(); mymodel.Ticket = LoadChiTietTicketUser(getid.ToString()); mymodel.Noidung = LoadNoiDung(getid.ToString()); var rep = collection["Reply"]; if (String.IsNullOrEmpty(rep) || Equals(rep, "<p><br></pr>")) { ViewData["Err"] = "(*) Vui lòng nhập nội dung !"; return(View(mymodel)); } else { tickets_text tx = new tickets_text(); tx.idUser_post = Int32.Parse(Session["dangnhap"].ToString()); tx.tText = rep; tx.idTicket = Int32.Parse(getid.ToString()); tx.DateSent = DateTime.Parse(DateTime.Now.ToString()); db.tickets_texts.InsertOnSubmit(tx); db.SubmitChanges(); var a = from b in db.tickets where Equals(b.idTicket, getid) select b; foreach (var d in a) { d.idUsetLastPost = Int32.Parse(Session["dangnhap"].ToString()); } db.SubmitChanges(); return(RedirectToAction("chitietyeucauhotro", "support", new { id = getid })); } }