public void Create_PostValidData_RedirectsToList()
        {
            var department = new Department
                                 {
                                     ContactEmail = "*****@*****.**",
                                     ContactName = "New Contact"
                                 };

            var result = _departmentController.Create(department) as RedirectToRouteResult;
            Assert.That(result.RouteValues["action"].ToString(), Is.EqualTo("List"));
        }
 public ActionResult Delete(Department department)
 {
     try
     {
         _departmentsDao.Delete(department);
         return RedirectToAction("List");
     }
     catch
     {
         return View();
     }
 }
        public ActionResult Create(Department department)
        {
            if (!ModelState.IsValid || department == null)
                return View(department);

            try
            {
                _departmentsDao.Add(department);
                return RedirectToAction("List");
            }
            catch
            {
                return View();
            }
        }
Esempio n. 4
0
        public void Add(Department department)
        {
            if (department == null) return;

            if (department.Id.Equals(new Guid("00000000-0000-0000-0000-000000000000")))
                department.Id = Guid.NewGuid();

            if (DepartmentExists(department))
            {
                Update(department);
                return;
            }

            IList<Department> departments = GetAll();

            department.SortOrder = departments.Count + 1;

            departments.Add(department);
            SaveAll(departments);
        }
Esempio n. 5
0
 void IDepartmentDao.Update(Department department)
 {
     throw new NotImplementedException();
 }
Esempio n. 6
0
 public void Delete(Department department)
 {
     throw new NotImplementedException();
 }
        private static IList<Department> GetSampleDepartments()
        {
            IList<Department> departments = new List<Department>();

            for (int i = 1; i < 5; i++)
            {
                var dep = new Department
                              {
                                  ContactName = "dep" + i,
                                  ContactEmail = "dep" + i + "@firm.no",
                                  SortOrder = i
                              };
                departments.Add(dep);
            }

            return departments;
        }
 public void Update(Department department)
 {
     //throw new NotImplementedException();
 }
Esempio n. 9
0
 private void BuildStartPage()
 {
     IList<Department> departments = _departmentDao.GetAll();
     NextDepartment = _departmentServices.GetFirstDepartmentInList(departments);
     CakeSchedule = _cakeScheduleServices.SetNextCakeDate(_cakeScheduleDao.Get(), DateTime.Now.Date);
 }
Esempio n. 10
0
 public void Setup()
 {
     _department = new Department();
 }
Esempio n. 11
0
 public ActionResult Edit(Department department)
 {
     if (ModelState.IsValid)
     {
         try
         {
             _departmentsDao.Add(department);
             return RedirectToAction("List");
         }
         catch
         {
             return View();
         }
     }
     return View(department);
 }
Esempio n. 12
0
        public void Delete(Department department)
        {
            IList<Department> departments = GetAll();

            List<Department> departmentsToKeep = (from d in departments
                                                  where d.Id != department.Id
                                                  select d).ToList();

            SaveAll(departmentsToKeep);
        }
Esempio n. 13
0
 private bool DepartmentExists(Department department)
 {
     return Get(department.Id) != null;
 }
Esempio n. 14
0
        public void Update(Department department)
        {
            IList<Department> departments = GetAll();

            Department departmentToUpdate = (from d in departments
                                             where d.Id == department.Id
                                             select d).FirstOrDefault();

            if (departmentToUpdate == null)
                return;

            departments.Remove(departmentToUpdate);
            departments.Add(department);
            SaveAll(departments);
        }