public TaskFormViewModel(Task task , Sprint sprint , User user, Code code, Story story) { TimeforingRepository repo = new TimeforingRepository(); Task = task; Sprint = SelectListMaker.SprintsWithSelected(Task); User = SelectListMaker.UsersWithSelected(Task); Code = SelectListMaker.CodesWithSelected(Task); Story = SelectListMaker.StoriesWithSelected(Task); }
public static List<SelectListItem> SprintsWithSelected(Task t) { var items = _repo.FindAllSprints().Where(s => s.Archived != true).Select(s => s); ; List<SelectListItem> list = new List<SelectListItem>(); foreach (var item in items) { SelectListItem i = new SelectListItem { Value = item.SprintID.ToString(), Text = item.Name, Selected = t.SprintID == item.SprintID }; list.Add(i); } return list; }
public static List<SelectListItem> CodesWithSelected(Task t) { var items = _repo.FindAllCodes(); List<SelectListItem> list = new List<SelectListItem>(); foreach (var item in items) { SelectListItem i = new SelectListItem { Value = item.CodeID.ToString(), Text = item.ProjectID + "/" + item.CodeNumber + " - " + item.Name, Selected = t.CodeID == item.CodeID }; list.Add(i); } return list; }
public ActionResult Create(string command, FormCollection collection) { Task t = new Task(); TaskFormViewModel tm = new TaskFormViewModel(t); try { UpdateModel(t); repo.AddTask(t); repo.Save(); if (command == "save") return RedirectToAction("Index"); TaskFormViewModel tmNew = new TaskFormViewModel(new Task(), t.Sprint , t.User, t.Code, t.Story); ResetTextValues(); return View(tmNew); } catch { ModelState.AddRuleViolations(t.GetRuleViolations()); return View(new TaskFormViewModel(t)); } }
public static List<SelectListItem> UsersWithSelected(Task t) { var items = _repo.FindAllUsers(); List<SelectListItem> list = new List<SelectListItem>(); foreach (var item in items) { SelectListItem i; i = new SelectListItem { Value = item.UserID.ToString(), Text = item.Name, Selected = t.UserID == item.UserID }; list.Add(i); } return list; }
public static List<SelectListItem> StoriesWithSelected(Task task) { var items = from s in _repo.FindAllStories() select s; List<SelectListItem> list = new List<SelectListItem>(); foreach (var item in items) { SelectListItem i; i = new SelectListItem { Value = item.StoryID.ToString(), Text = item.Name, Selected = task.StoryID == item.StoryID }; list.Add(i); } return list; }
partial void DeleteTask(Task instance);
private void detach_Tasks(Task entity) { this.SendPropertyChanging(); entity.User = null; }
partial void UpdateTask(Task instance);
private void attach_Tasks(Task entity) { this.SendPropertyChanging(); entity.User = this; }
partial void InsertTask(Task instance);