Example #1
0
        public ActionResult AddWorker(WorkerFormModel model)
        {
            if (!ModelState.IsValid)
            {
                model.Companies = companiesService.GetCompaniesList();

                return(View(model));
            }

            try
            {
                workersService.SaveWorker(model);
            }
            catch (System.Exception ex)
            {
                return(RedirectToAction("GetWorkersList", new { errorMessage = ex.Message }));
            }

            return(RedirectToAction("GetWorkersList"));
        }
Example #2
0
        // Display companies list
        public ActionResult GetCompaniesList(string errorMessage)
        {
            ViewBag.Title = "Companies list";

            ViewBag.ErrorMessage = errorMessage;

            List <Company> model;

            try
            {
                model = companiesService.GetCompaniesList();
            }
            catch (System.Exception ex)
            {
                ViewBag.ErrorMessage = ex.Message;
                return(View());
            }

            return(View(model));
        }