public ActionResult AssignTaskClass(assignTask assignTask, String TFS) { int facId = Convert.ToInt32(Session["id"].ToString()); if (facultyModel.SaveAssignTask(assignTask, facId, TFS)) { return(RedirectToAction("AssignTaskClass")); } else { TempData["error"] = "Something Went Wrong"; return(RedirectToAction("AssignTaskClass")); } }
public bool SaveAssignTask(assignTask assignTask, int facId, string tFS) { try { assignTask.classId = db.assignFacSubs.Where(x => x.facId == facId && x.sem == assignTask.sem).FirstOrDefault().classId; assignTask.facId = facId; assignTask.startDate = DateTime.Now; assignTask.endDate = assignTask.startDate.AddDays(Convert.ToInt32(tFS)); db.assignTasks.Add(assignTask); db.SaveChanges(); return(true); } catch (Exception e) { return(false); } }