public ActionResult CreateTask(FormCollection form) { string Name = form["TaskName"]; string Priority = form["TaskPriority"]; string AssignUser = form["User"]; string id = form["id"]; TaskRepo taskRepo = new TaskRepo(context); if (taskRepo.findIfPriorityandNameExists(Int32.Parse(Priority), Name.ToLower())) { SetFlash(FlashMessageType.Error, "this priority is already assigned to a task"); } else { Tasks task = new Tasks() { Name = Name.ToLower(), Priority = Int32.Parse(Priority), ActvityId = Int32.Parse(id), AssignTo = AssignUser, Status = "1" }; taskRepo.Add(task); SetFlash(FlashMessageType.Success, "Task has been successfuly added"); } return(RedirectToAction("Index")); }