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> CodesWithSelected(Code c) { var items = _repo.FindAllCodes(); List<SelectListItem> list = new List<SelectListItem>(); foreach (var item in items) { SelectListItem i; i = new SelectListItem { Value = item.CodeID.ToString(), Text = item.Name, Selected = c.CodeID == item.CodeID }; list.Add(i); } return list; }
public ActionResult Create(FormCollection collection) { Code c = new Code(); try { UpdateModel(c); repo.AddCode(c ); repo.Save(); return RedirectToAction("Index"); } catch (System.Data.SqlClient.SqlException ) { ModelState.AddModelError("ProjectID", "Prosjektnummer finnes ikke"); return View(c); } catch { ModelState.AddRuleViolations(c .GetRuleViolations()); return View(c); } }
public CodeFormViewModel(Code code) { TimeforingRepository repo = new TimeforingRepository (); Code = code; ProjectCodes = SelectListMaker.Projects(); }
private void detach_Codes(Code entity) { this.SendPropertyChanging(); entity.Project = null; }
private void attach_Codes(Code entity) { this.SendPropertyChanging(); entity.Project = this; }
partial void DeleteCode(Code instance);
partial void UpdateCode(Code instance);
partial void InsertCode(Code instance);
// // GET: /Code/Create public ActionResult Create() { Code c = new Code(); CodeFormViewModel v = new CodeFormViewModel(c); return View(v); }