public async Task <IActionResult> Create(IFormFile FileContent, [Bind("PhaseActivityName,PhaseActivityProgress,Budget,RealCosts,Expense,PhaseActivityStartDatePlanned,PhaseActivityEndDatePlanned,PhaseActivityStartDateRealized,PhaseActivityEndDateRealized,EmployeeId,PhaseId,StatusId,ProjectId,Id")] PhasesActivity phasesActivity)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    byte[] fileData = null;

                    // read file to byte array
                    using (var binaryReader = new BinaryReader(FileContent.OpenReadStream()))
                    {
                        fileData = binaryReader.ReadBytes((int)FileContent.Length);
                    }
                    phasesActivity.FileContent = fileData;
                }
                catch (Exception e)
                {
                    Console.WriteLine("test");
                }
                _context.Add(phasesActivity);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }

            ViewData["EmployeeId"] = new SelectList(_context.Employees, "Id", "EmployeeFirstName", phasesActivity.EmployeeId);
            ViewData["PhaseId"]    = new SelectList(_context.Phases, "Id", "PhaseName", phasesActivity.PhaseId);
            ViewData["StatusId"]   = new SelectList(_context.Status, "Id", "StatusType", phasesActivity.StatusId);
            return(View(phasesActivity));
        }
コード例 #2
0
        public async Task <IActionResult> Create([Bind("PriorityType,Id")] Priority priority)
        {
            if (ModelState.IsValid)
            {
                _context.Add(priority);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(priority));
        }
コード例 #3
0
        public async Task <IActionResult> Create([Bind("FunctionTyp,Id")] Function function)
        {
            if (ModelState.IsValid)
            {
                _context.Add(function);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(function));
        }
コード例 #4
0
        public async Task <IActionResult> Create([Bind("StatusType,Id")] Status status)
        {
            if (ModelState.IsValid)
            {
                _context.Add(status);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(status));
        }
コード例 #5
0
        public async Task <IActionResult> Create([Bind("DepartmentName,Id")] Department department)
        {
            if (ModelState.IsValid)
            {
                _context.Add(department);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(department));
        }
コード例 #6
0
        public async Task <IActionResult> Create([Bind("ProcedureModelName,ProcedureModelName")] ProcedureModel procedureModel)
        {
            if (ModelState.IsValid)
            {
                _context.Add(procedureModel);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(procedureModel));
        }
コード例 #7
0
        public async Task <IActionResult> Create([Bind("PhaseName,PhaseReview,PhaseStartDatePlanned,PhaseEndDatePlanned,PhaseStartDateRealized,PhaseEndDateRealized,PhaseProgress,ProjectId,StatusId,Id")] Phase phase)
        {
            if (ModelState.IsValid)
            {
                _context.Add(phase);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ProjectId"] = new SelectList(_context.Projects, "Id", "ProjectTitle", phase.ProjectId);
            ViewData["StatusId"]  = new SelectList(_context.Status, "Id", "StatusType", phase.StatusId);
            return(View(phase));
        }
コード例 #8
0
        public async Task <IActionResult> Create([Bind("EmployeeFirstName,EmployeeLastName,EmployeeNumber,EmployeeWorkload,FunctionId,DepartmentId,Id")] Employee employee)
        {
            if (ModelState.IsValid)
            {
                _context.Add(employee);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["DepartmentId"] = new SelectList(_context.Departments, "Id", "DepartmentName", employee.DepartmentId);
            ViewData["FunctionId"]   = new SelectList(_context.Functions, "Id", "FunctionTyp", employee.FunctionId);
            return(View(employee));
        }
コード例 #9
0
        public async Task <IActionResult> Create([Bind("ExternalCostTitle,ExternalCostAmountPlanned,ExternalCostAmountReal,CostId,PhaseActivityId,Id")] ExternalCost externalCost)
        {
            if (ModelState.IsValid)
            {
                _context.Add(externalCost);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CostId"]          = new SelectList(_context.Costs, "Id", "CostTyp", externalCost.CostId);
            ViewData["PhaseActivityId"] = new SelectList(_context.PhasesActivities, "Id", "PhaseActivityName", externalCost.PhaseActivityId);
            return(View(externalCost));
        }
コード例 #10
0
        public async Task <IActionResult> Create([Bind("ResourceTitle,ResourcePlanned,ResourceReal,RessourceDeviation,FunctionId,PhaseActivityId,Id")] PersonnelResource personnelResource)
        {
            if (ModelState.IsValid)
            {
                _context.Add(personnelResource);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["FunctionId"]      = new SelectList(_context.Functions, "Id", "FunctionTyp", personnelResource.FunctionId);
            ViewData["PhaseActivityId"] = new SelectList(_context.PhasesActivities, "Id", "PhaseActivityName", personnelResource.PhaseActivityId);
            return(View(personnelResource));
        }
コード例 #11
0
        public async Task <IActionResult> Create([Bind("MilestoneName,MilestoneDate,ProjectId,PhaseId,Id")] Milestone milestone)
        {
            if (ModelState.IsValid)
            {
                _context.Add(milestone);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["PhaseId"]   = new SelectList(_context.Phases, "Id", "PhaseName", milestone.PhaseId);
            ViewData["ProjectId"] = new SelectList(_context.Projects, "Id", "ProjectTitle", milestone.ProjectId);
            return(View(milestone));
        }
コード例 #12
0
        public async Task <IActionResult> Create([Bind("ProjectTitle,ProjectDescription,ProjectApprovalDate,ProjectStartDatePlanned,ProjectEndDatePlanned,ProjectStartDateRealized,ProjectEndDateRealized,ProjectProgress,EmployeeId,PriorityId,ProcedureModelId,StatusId,Id")] Project project)
        {
            if (ModelState.IsValid)
            {
                _context.Add(project);
                await _context.SaveChangesAsync();

                ProcedureModel procedureModel = _context.ProcedureModels.ToList().Find(_procedureModel => _procedureModel.Id == project.ProcedureModelId);

                List <Phase> generatedPhases = new List <Phase>();

                // Hermes Create Phase
                if (procedureModel.ProcedureModelName == "Hermes")
                {
                    generatedPhases.AddRange(new List <Phase>()
                    {
                        new Phase()
                        {
                            ProjectId = project.Id,
                            PhaseName = "Initialisierung - " + project.ProjectTitle
                        },
                        new Phase()
                        {
                            ProjectId = project.Id,
                            PhaseName = "Konzept - " + project.ProjectTitle
                        },
                        new Phase()
                        {
                            ProjectId = project.Id,
                            PhaseName = "Realisierung - " + project.ProjectTitle
                        },
                        new Phase()
                        {
                            ProjectId = project.Id,
                            PhaseName = "Einführung - " + project.ProjectTitle
                        }
                    }
                                             );
                }

                // V-Modell Create Phase
                if (procedureModel.ProcedureModelName == "V-Modell")
                {
                    generatedPhases.AddRange(new List <Phase>()
                    {
                        new Phase()

                        {
                            ProjectId = project.Id,
                            PhaseName = "Systemanforderungsanalyse - " + project.ProjectTitle
                        },
                        new Phase()
                        {
                            ProjectId = project.Id,
                            PhaseName = "System Architektur und Entwurf - " + project.ProjectTitle
                        },
                        new Phase()
                        {
                            ProjectId = project.Id,
                            PhaseName = "Software Architektur und Entwurf - " + project.ProjectTitle
                        },
                        new Phase()
                        {
                            ProjectId = project.Id,
                            PhaseName = "Unit und Integrations Test - " + project.ProjectTitle
                        },
                        new Phase()
                        {
                            ProjectId = project.Id,
                            PhaseName = "System Integration - " + project.ProjectTitle
                        },
                        new Phase()
                        {
                            ProjectId = project.Id,
                            PhaseName = "Abnahme und Nutzung - " + project.ProjectTitle
                        }
                    }
                                             );
                }

                //  Create Milestones
                if (generatedPhases.Count > 0)
                {
                    _context.AddRange(generatedPhases);
                    await _context.SaveChangesAsync();

                    try
                    {
                        List <Milestone> milestones = new List <Milestone>();
                        foreach (Phase currentPhase in generatedPhases)
                        {
                            milestones.Add(new Milestone()
                            {
                                PhaseId       = currentPhase.Id,
                                ProjectId     = project.Id,
                                MilestoneDate = DateTime.Now,
                                MilestoneName = "Milestone - " + currentPhase.PhaseName
                            });
                        }
                        _context.AddRange(milestones);
                        await _context.SaveChangesAsync();
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("Fehler2: " + e.ToString());
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["EmployeeId"]       = new SelectList(_context.Employees, "Id", "EmployeeFirstName", project.EmployeeId);
            ViewData["PriorityId"]       = new SelectList(_context.Priorities, "Id", "PriorityType", project.PriorityId);
            ViewData["ProcedureModelId"] = new SelectList(_context.ProcedureModels, "Id", "ProcedureModelName", project.ProcedureModelId);
            ViewData["StatusId"]         = new SelectList(_context.Set <Status>(), "Id", "StatusType", project.StatusId);
            return(View(project));
        }