예제 #1
0
 public ActionResult Edit(Company company)
 {
     using (var cm = new CompanyManager())
     {
         company = cm.Edit(company);
     }
     return RedirectToAction("List");
 }
예제 #2
0
 public ActionResult Create()
 {
     using (var cm = new CompanyManager())
     {
         ViewBag.CompanyList = cm.All().ToList();
     }
     ViewBag.User = new User();
     return View("Edit");
 }
예제 #3
0
 public ActionResult Edit(int id)
 {
     using (var cm = new CompanyManager())
     {
         var company = cm.Single(id);
         ViewBag.Company = company;
         return View("Edit");
     }
 }
예제 #4
0
        public ActionResult List()
        {
            List<Company> companies;

            using (var cm = new CompanyManager())
            {
                companies = cm.All().ToList();
            }

            ViewBag.Companies = companies;
            return View("CompanyList");
        }
예제 #5
0
 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");
     }
 }
예제 #6
0
        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);
        }
예제 #7
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});
 }
예제 #8
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);
            }
        }