public ActionResult Details(int id)
        {
            var serviceRequest = serviceRequestRepository.Get(id);
            var viewModel      = new ServiceRequestFormViewModel
            {
                ServiceRequest = serviceRequest
            };

            return(View(viewModel));
        }
        public ActionResult Insert()
        {
            var clients   = clientRepository.GetAll().OrderBy(l => l.Name);
            var services  = serviceRepository.GetAll().OrderBy(s => s.ServiceName);
            var viewModel = new ServiceRequestFormViewModel
            {
                Clients  = clients,
                Services = services
            };

            return(View(viewModel));
        }
        public ActionResult CreateOrUpdate(ServiceRequestFormViewModel viewModel) // model binding
        {
            if (viewModel.ServiceRequest.Id == 0)                                 // Create
            {
                var fakeId = int.Parse(Request.Cookies["LoginId"].Value);
                var id     = clientRepository.Get(fakeId).Id;

                viewModel.ServiceRequest.ClientId = id;
                viewModel.ServiceRequest.Status   = Entities.Status.Pending;
                serviceRequestRepository.Insert(viewModel.ServiceRequest);
                return(RedirectToAction("Index", "Client"));
            }
            else // Update
            {
                var serviceRequest = serviceRequestRepository.Update(viewModel.ServiceRequest);
                return(RedirectToAction("ServiceRequestList", "ServiceRequest"));
            }
        }
        public ActionResult Edit(int id)
        {
            var serviceRequest = serviceRequestRepository.Get(id);
            var clients        = clientRepository.GetAll().OrderBy(l => l.Name);
            var services       = serviceRepository.GetAll().OrderBy(s => s.ServiceName);

            if (serviceRequest == null)
            {
                return(HttpNotFound());
            }
            var viewModel = new ServiceRequestFormViewModel
            {
                ServiceRequest = serviceRequest,
                Clients        = clients,
                Services       = services
            };

            return(View(viewModel));
        }