// GET: Tasks public async Task <ActionResult> Tasks() { var cmpID = 0; Users item = new Users(); if (Session["useDetails"] != null) { item = Session["useDetails"] as Users; } TasksModel model = new TasksModel(); cmpID = item.useCompanyID; List <TypeModel> typModel = new List <TypeModel>(); List <Users> usrModel = new List <Users>(); List <Users> toModel = new List <Users>(); List <PriorityModel> ptyModel = new List <PriorityModel>(); List <StatusModel> staModel = new List <StatusModel>(); UserContext useContext = new UserContext(); TypeContext typContext = new TypeContext(); PriorityContext ptyContext = new PriorityContext(); StatusContext staContext = new StatusContext(); usrModel = await usVM.GetUserConnection(cmpID); //toModel = useContext.ToUsersDropDown(cmpID); typModel = typContext.TypeDropDown(); ptyModel = ptyContext.PriorityDropDown(); staModel = staContext.StatusDropDown(); foreach (var user in usrModel) { model.Users.Add(new SelectListItem { Text = user.useName, Value = user.useID.ToString() }); } //foreach (var user in toModel) //{ // model.ToUsers.Add(new SelectListItem { Text = user.useName, Value = user.useID.ToString() }); //} foreach (var type in typModel) { model.Types.Add(new SelectListItem { Text = type.typName, Value = type.typID.ToString() }); } foreach (var priority in ptyModel) { model.Priorites.Add(new SelectListItem { Text = priority.ptyName, Value = priority.ptyID.ToString() }); } foreach (var status in staModel) { model.Status.Add(new SelectListItem { Text = status.staName, Value = status.staID.ToString() }); } return(View(model)); }
public async Task <ActionResult> AddTask(TasksModel tasks, HttpPostedFileBase[] postedFile) { var useID = 0; var cmpID = 0; var cmpName = ""; var item = Session["useDetails"] as Users; useID = item.useID; cmpID = item.useCompanyID; cmpName = item.useCompanyName; TasksModel model = new TasksModel(); List <CompanyModel> cmpModel = new List <CompanyModel>(); List <TypeModel> typModel = new List <TypeModel>(); List <PriorityModel> ptyModel = new List <PriorityModel>(); List <Users> usrModel = new List <Users>(); TypeContext typContext = new TypeContext(); CompanyContext cmpContext = new CompanyContext(); PriorityContext ptyContext = new PriorityContext(); UserContext useContext = new UserContext(); cmpModel = await cnnVM.CompanyConnectionDropDown(cmpID, cmpName); typModel = typContext.TypeDropDown(); ptyModel = ptyContext.PriorityDropDown(); usrModel = useContext.UsersDropDownController(cmpID); foreach (var country in cmpModel) { model.Companies.Add(new SelectListItem { Text = country.cmpName, Value = country.cmpID.ToString() }); } foreach (var type in typModel) { model.Types.Add(new SelectListItem { Text = type.typName, Value = type.typID.ToString() }); } foreach (var priority in ptyModel) { model.Priorites.Add(new SelectListItem { Text = priority.ptyName, Value = priority.ptyID.ToString() }); } foreach (var user in usrModel) { model.Users.Add(new SelectListItem { Text = user.useName, Value = user.useID.ToString() }); } model.tasDelagatedBy = tasks.tasDelagatedBy; model.tasDelegatedTo = tasks.tasDelegatedTo; //if (tasks.tasType > 0 && !string.IsNullOrWhiteSpace(tasks.tasTitle)) //{ // if (ModelState.IsValid == false) // { // return View(model); // } // else // { // var response = await taskVm.AddTask(tasks, postedFile); // if (response == true) // { // return RedirectToAction("Tasks"); // } // else // { // return View(model); // } // } //} //else //{ // ViewBag.CompanyID = tasks.tasDelegatedTo_Company; // return View(model); //} ViewBag.CompanyID = tasks.tasDelegatedTo_Company; return(View(model)); }
public async Task <ActionResult> AddTask() { var useID = 0; var cmpID = 0; var cmpName = ""; Users item; if (Session["useDetails"] != null) { item = Session["useDetails"] as Users; useID = item.useID; cmpID = item.useCompanyID; cmpName = item.useCompanyName; } TasksModel model = new TasksModel(); List <CompanyModel> cmpModel = new List <CompanyModel>(); List <TypeModel> typModel = new List <TypeModel>(); List <PriorityModel> ptyModel = new List <PriorityModel>(); List <Users> usrModel = new List <Users>(); CompanyContext cmpContext = new CompanyContext(); TypeContext typContext = new TypeContext(); PriorityContext ptyContext = new PriorityContext(); UserContext useContext = new UserContext(); cmpModel = await cnnVM.CompanyConnectionDropDown(cmpID, cmpName); typModel = typContext.TypeDropDown(); ptyModel = ptyContext.PriorityDropDown(); usrModel = useContext.UsersDropDownController(cmpID); model.tasID = cmpID; foreach (var company in cmpModel) { model.Companies.Add(new SelectListItem { Text = company.cmpName, Value = company.cmpID.ToString() }); } foreach (var type in typModel) { model.Types.Add(new SelectListItem { Text = type.typName, Value = type.typID.ToString() }); } foreach (var priority in ptyModel) { model.Priorites.Add(new SelectListItem { Text = priority.ptyName, Value = priority.ptyID.ToString() }); } foreach (var user in usrModel) { model.Users.Add(new SelectListItem { Text = user.useName, Value = user.useID.ToString() }); } model.tasDelagatedBy = useID; return(View(model)); }