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