public ActionResult Edit(int id) { using (var cm = new CompanyManager()) { var company = cm.Single(id); ViewBag.Company = company; return View("Edit"); } }
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); } }
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}); }