public ActionResult SendRequest(String stu, String context, String name) { var adminID = AccBO.GetUserByUsername(name).UserID; List <Student> students = StuBO.GetActiveStudents(); if (stu == "All") { foreach (var student in students) { var req = new Request(); req.StudentID = student.StudentID; req.Context = context; req.CreatedAdminID = adminID; ReBO.Insert(req); } } else { String[] tmp = stu.Split(','); for (int i = 0; i < tmp.Length; i++) { var req = new Request(); req.StudentID = int.Parse(tmp[i]); req.Context = context; req.CreatedAdminID = adminID; ReBO.Insert(req); } } return(RedirectToAction("StudentRequest")); }
public bool Insert(Request request) { try { using (var u = new RequestBusiness()) { u.Insert(request); return(true); } } catch (Exception ex) { Console.WriteLine(ex); return(false); } }
public IHttpActionResult Post([FromBody] Request request) { try { using (var c = new RequestBusiness()) { if (c.Insert(request)) { return(Ok()); } return(NotFound()); } } catch (Exception ex) { return(BadRequest($"{ex}")); } }