public ActionResult Edit(Company company) { using (var cm = new CompanyManager()) { company = cm.Edit(company); } return RedirectToAction("List"); }
public ActionResult Create() { using (var cm = new CompanyManager()) { ViewBag.CompanyList = cm.All().ToList(); } ViewBag.User = new User(); return View("Edit"); }
public ActionResult Edit(int id) { using (var cm = new CompanyManager()) { var company = cm.Single(id); ViewBag.Company = company; return View("Edit"); } }
public ActionResult List() { List<Company> companies; using (var cm = new CompanyManager()) { companies = cm.All().ToList(); } ViewBag.Companies = companies; return View("CompanyList"); }
public ActionResult Edit(int id) { using (var cm = new CompanyManager()) { ViewBag.CompanyList = cm.All().OrderBy(c => c.Name).ToList(); } using (var um = new UserManager()) { var user = um.Single(id); ViewBag.User = user; return View("Edit"); } }
public void CreateCompanyTest() { var company = new Company { Address = "460 South Marion pkwy apt 1402", City = "Denver", Email = "*****@*****.**", Name = "Third Company", Phone = "815-919-5371", State = "CO", Zip = "80209" }; using (var cm = new CompanyManager()) { company = cm.Create(company); } Assert.IsTrue(company.ID > 0); }
public ActionResult Profile() { Company company; using (var um = new UserManager()) { int companyID = 0; // any user tied to a company can only see their users var currentUser = um.ByUsername(User.Identity.Name); if (currentUser.CompanyID != null) { companyID = currentUser.CompanyID.GetValueOrDefault(); } using (var cm = new CompanyManager()) { company = cm.Single(companyID); } } return RedirectToAction("Edit", "Company", new { id = company.ID}); }
public void EditCompanyTest() { Company company; using (var cm = new CompanyManager()) { company = cm.Single(1); } var oldTime = company.ModifiedOn; company.ModifiedOn = DateTime.Now; using (var cm = new CompanyManager()) { company = cm.Edit(company); } using(var cm = new CompanyManager()) { var company2 = cm.Single(1); Assert.IsTrue(company2.ModifiedOn > oldTime); } }