예제 #1
0
        public ActionResult Create([Bind(Exclude = "d")] Employees empl)
        {
            SelectList positions = new SelectList(employeesDAO.GetAllPosition());

            ViewBag.Position = positions;
            int id = employeesDAO.AddEmployees(empl);

            switch (empl.Position)
            {
            case "водитель":
                try
                {
                    if (id > 0)
                    {
                        return(RedirectToAction("CreateDriver/" + id));
                    }
                    else
                    {
                        return(View("Create"));
                    }
                }
                catch
                {
                    return(View("Create"));
                }


            case "механик":
                try
                {
                    if (id > 0)
                    {
                        return(RedirectToAction("CreateMechanic/" + id));
                    }
                    else
                    {
                        return(View("Create"));
                    }
                }
                catch
                {
                    return(View("Create"));
                }

            case "кондуктор":
                try
                {
                    if ((id > 0) && (conductorDAO.AddConductor(id)))
                    {
                        return(RedirectToAction("IndexH"));
                    }
                    else
                    {
                        return(View("Create"));
                    }
                }
                catch
                {
                    return(View("Create"));
                }

            default:
                try
                {
                    if (id > 0)
                    {
                        return(RedirectToAction("IndexH"));
                    }
                    else
                    {
                        return(View("Create"));
                    }
                }
                catch
                {
                    return(View("Create"));
                }
            }
        }