public ActionResult Index(List <Item> items) { if (items != null) { foreach (var v in items) { if (v.ItemId == 0 || v.Quantity < 1) { return(new HttpStatusCodeResult(400)); } } try { int departmentId = Convert.ToInt32(RouteData.Values["departmentId"]); int userId = Convert.ToInt32(RouteData.Values["userId"]); Department d = new Department() { DepartmentId = Convert.ToInt32(departmentId) }; User u = new User() { UserId = userId, Department = d }; RequestDao.InsertRequest(items, u); Task.Run(() => EmailUtility.SendEmailForApproval(departmentId)); return(new HttpStatusCodeResult(200)); } catch (Exception e) { Debug.WriteLine(e.Message); return(new HttpStatusCodeResult(400)); } } else { return(new HttpStatusCodeResult(400)); } }