public ActionResult NewServiceUser()
        {
            //var repo = new StaffRepository().GetStaff().ToList();

            var viewModel = new ServiceUserFormVM
            {
                ServiceUser = new ServiceUser()
            };

            return(View("ServiceUserForm", viewModel));
        }
        public ActionResult Edit(int id)
        {
            var         viewModel = new ServiceUserFormVM();
            ServiceUser b         = _serviceUserRepository
                                    .GetAll()
                                    .ToList()
                                    .SingleOrDefault(v => v.Id == id);

            if (b == null)
            {
                return(HttpNotFound());
            }
            else
            {
                viewModel.ServiceUser = b;
                viewModel.staff       = _staffRepository.GetAll().SingleOrDefault(s => s.Id == b.staff.Id);
            }

            return(View("ServiceUserForm", viewModel));
        }
 public ActionResult Save(ServiceUser serviceUser)
 {
     if (!ModelState.IsValid)
     {
         var viewModel = new ServiceUserFormVM
         {
             ServiceUser = serviceUser,
             staff       = _staffRepository
                           .GetAll()
                           .SingleOrDefault(n => n.Id == serviceUser.StaffId)
         };
         return(View("ServiceUserForm", viewModel));
     }
     if (serviceUser.Id == 0)
     {
         _serviceUserRepository.Create(serviceUser);
     }
     else
     {
         _serviceUserRepository.Update(serviceUser);
     }
     return(RedirectToAction("Index", "ServiceUser"));
 }