예제 #1
0
        public ActionResult CreateLabProject(Labs laboratory)
        {
            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 listLabScopes = labScop.ListLabScopes();

            ViewBag.listLabScopesDll = new SelectList(listLabScopes, "Lab_scope_id", "Lab_scope_name");

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

                    var labToAdd = Mapper.Map <DATA.Labs>(laboratory);
                    lab.AddLabs(labToAdd);
                    int x = (Int32)Session["UserType"];
                    switch (x)
                    {
                    case 1:
                        return(RedirectToAction("PmProjects", "User"));

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

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

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

                    default:
                        return(RedirectToAction("Index", "Home"));
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
            else
            {
                return(View());
            }
        }
예제 #2
0
        public ActionResult CreateLabProject(Labs laboratory)
        {
            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 listLabScopes = labScop.ListLabScopes();

            ViewBag.listLabScopesDll = new SelectList(listLabScopes, "Lab_scope_id", "Lab_scope_name");

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

                    var labToAdd = Mapper.Map <DATA.Labs>(laboratory);
                    lab.AddLabs(labToAdd);
                    return(RedirectToAction("CreateLabProject"));
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
            else
            {
                return(View());
            }
        }