コード例 #1
0
        public ActionResult CreateFactoryProject(Factories factory)
        {
            var listProjectType = proType.ListProjectTypes();

            ViewBag.listProjectTypeDll = new SelectList(listProjectType, "Project_type_id", "Project_type_name");

            var listPhaseTypes = phaseType.ListPhaseTypes();

            ViewBag.listPhaseTypesDll = new SelectList(listPhaseTypes, "Phase_id", "Phase_name");

            var listSpeedConnectionsTypes = speedType.ListSpeedConnectionTypes();

            ViewBag.listSpeedConnectionsTypesDll = new SelectList(listSpeedConnectionsTypes, "Speed_connection_id", "Speed_connection_name");

            var listFacScope = fabScop.ListFabScopes();

            ViewBag.listFabScopesDll = new SelectList(listFacScope, "Fab_scope_id", "Fab_scope_name");

            if (factory.Factory_requestor_id != null)
            {
                //Changes the lab project null to 2=Laboratory
                factory.Project_type = 3;
                try
                {
                    if (!ModelState.IsValid)
                    {
                        return(View());
                    }

                    var fabToAdd = Mapper.Map <DATA.Factories>(factory);
                    fac.AddFactory(fabToAdd);
                    int x = (Int32)Session["UserType"];
                    switch (x)
                    {
                    case 1:
                        return(RedirectToAction("PmProjects", "User"));

                    case 2:
                        return(RedirectToAction("UserMyProjects", "User"));

                    case 3:
                        return(RedirectToAction("Index", "Factory"));

                    case 4:
                        return(RedirectToAction("Index", "Factory"));

                    default:
                        return(RedirectToAction("Index", "Home"));
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
            else
            {
                return(View());
            }
        }
コード例 #2
0
        public ActionResult CreateFactoryProject(Factories factory)
        {
            var listProjectType = proType.ListProjectTypes();

            ViewBag.listProjectTypeDll = new SelectList(listProjectType, "Project_type_id", "Project_type_name");

            var listPhaseTypes = phaseType.ListPhaseTypes();

            ViewBag.listPhaseTypesDll = new SelectList(listPhaseTypes, "Phase_id", "Phase_name");

            var listSpeedConnectionsTypes = speedType.ListSpeedConnectionTypes();

            ViewBag.listSpeedConnectionsTypesDll = new SelectList(listSpeedConnectionsTypes, "Speed_connection_id", "Speed_connection_name");

            var listFacScope = fabScop.ListFabScopes();

            ViewBag.listFabScopesDll = new SelectList(listFacScope, "Fab_scope_id", "Fab_scope_name");

            if (factory.Factory_requestor_id != null)
            {
                //Changes the lab project null to 2=Laboratory
                factory.Project_type = 3;
                try
                {
                    if (!ModelState.IsValid)
                    {
                        return(View());
                    }

                    var fabToAdd = Mapper.Map <DATA.Factories>(factory);
                    fac.AddFactory(fabToAdd);
                    return(RedirectToAction("CreateFactoryProject"));
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
            else
            {
                return(View());
            }
        }