예제 #1
0
        public IActionResult Top3(Top3ViewModel model)
        {
            var fullName = _userManager.FindByNameAsync(User.Identity.Name).Result.Fullname;
            var exists   = ctx.Top3.FirstOrDefault(x => x.ProjectLeader == fullName);

            if (exists != null)
            {
                exists.Option1 = model.Option1;
                exists.Option2 = model.Option2;
                exists.Option3 = model.Option3;
                ctx.Top3.Update(exists);
                ctx.SaveChanges();
            }
            else
            {
                var newEntry = new DBModels.Top3
                {
                    ProjectLeader = fullName,
                    Option1       = model.Option1,
                    Option2       = model.Option2,
                    Option3       = model.Option3
                };
                ctx.Top3.Add(newEntry);
                ctx.SaveChanges();
            }

            return(RedirectToAction("ViewProjects", "Project"));
        }
예제 #2
0
        private void CheckIfLate(ApplicationUser user)
        {
            var projects     = ctx.Masterplan.Where(x => x.ProjectLeader == user.Fullname && x.Status == "IN PROGRESS").ToList();
            var date2Compare = DateTime.Now;

            foreach (var project in projects)
            {
                var late = ctx.ProjectLate.FirstOrDefault(x => x.ProjectId == project.Id);
                if (late == null)
                {
                    ctx.ProjectLate.Add(new ProjectLate
                    {
                        ProjectId           = project.Id,
                        ConceptualLate      = false,
                        StartupLate         = false,
                        FesabilityLate      = false,
                        DesignConstructLate = false,
                        DefinitionLate      = false
                    });
                    ctx.SaveChanges();
                }

                late = ctx.ProjectLate.FirstOrDefault(x => x.ProjectId == project.Id);

                if (date2Compare.CompareTo(project.FesabilityEnd) > 0 && project.FesabilityCompletetd == false)
                {
                    late.FesabilityLate = true;
                }

                if (date2Compare.CompareTo(project.ConceptualEnd) > 0 && project.ConceptualCompleted == false)
                {
                    late.ConceptualLate = true;
                }

                if (date2Compare.CompareTo(project.DesignConstructEnd) > 0 && project.DesignConstructcCompleted == false)
                {
                    late.DesignConstructLate = true;
                }

                if (date2Compare.CompareTo(project.DefinitionEnd) > 0 && project.DefinitionDone == false)
                {
                    late.DefinitionLate = true;
                }

                if (date2Compare.CompareTo(project.PredictedEndDate) > 0 && project.Status != "COMPLETE")
                {
                    late.FesabilityLate = true;
                }

                ctx.Update(late);
                ctx.SaveChanges();
            }
        }
예제 #3
0
        public async Task <IActionResult> AddProject(AddProjectViewModel model, string errorMessage = null)
        {
            ViewBag.ErrorMessage = errorMessage;
            if (ModelState.IsValid)
            {
                if (CompareDate(model.StartDate, model.FesabilityEndDate.Value))
                {
                    return(await AddProject(model, "Feasibility: End Date is before Start Date"));
                }
                if (CompareDate(model.FesabilityEndDate.Value, model.ConceptualEndDate.Value))
                {
                    return(await AddProject(model, "Conceptual: End Date is before Start Date"));
                }
                if (CompareDate(model.ConceptualEndDate.Value, model.DefinitionEndDate.Value))
                {
                    return(await AddProject(model, "Definition: End Date is before Start Date"));
                }
                if (CompareDate(model.DefinitionEndDate.Value, model.DesignConstructEndDate.Value))
                {
                    return(await AddProject(model, "Design&Construct: End Date is before Start Date"));
                }
                if (CompareDate(model.DesignConstructEndDate.Value, model.PredictedEndDate))
                {
                    return(await AddProject(model, "Startup: End Date is before Start Date"));
                }

                if (model.StartupLeader == null && model.AdditionalStartupLeader == null)
                {
                    return(AddProject("Select Startup leader or add a new one!"));
                }

                if (model.AdditionalPcisResource != null)
                {
                    ctx.Pcisresource.Add(new Pcisresource {
                        Name = model.AdditionalPcisResource
                    });
                    ctx.SaveChanges();
                }

                if (model.AdditionalPTResource != null)
                {
                    ctx.Ptresource.Add(new Ptresource {
                        Name = model.AdditionalPTResource
                    });
                    ctx.SaveChanges();
                }
                if (model.AdditionalEIResource != null)
                {
                    ctx.Eiresource.Add(new Eiresource {
                        Name = model.AdditionalEIResource
                    });
                    ctx.SaveChanges();
                }
                if (model.AdditionalStartupLeader != null)
                {
                    ctx.Leaders.Add(new Leaders {
                        Name = model.AdditionalStartupLeader
                    });
                    ctx.SaveChanges();
                }

                Masterplan project2Add = new Masterplan
                {
                    ActualEndDate           = null,
                    ActualEndFiscalYear     = null,
                    ActualSpendingTargetEtc = false,
                    Category                    = model.Category,
                    Cm                          = model.CM,
                    ConceptualActualEnd         = null,
                    ConceptualComments          = null,
                    ConceptualCompleted         = false,
                    ConceptualDeliverables      = null,
                    ConceptualEnd               = model.ConceptualEndDate,
                    DefinitionActualEnd         = null,
                    DefinitionComments          = null,
                    DefinitionDeliverables      = null,
                    DefinitionDone              = false,
                    DefinitionEnd               = model.DefinitionEndDate,
                    DesignConstructActualEnd    = null,
                    DesignConstructcCompleted   = false,
                    DesignConstructComments     = null,
                    DesignConstructDeliverables = null,
                    DesignConstructEnd          = model.DesignConstructEndDate,
                    Eiresource                  = model.AdditionalEIResource ?? model.EIResource,
                    Etc                         = model.ETC,
                    Saving                      = model.Savings,
                    FesabilityActualEnd         = null,
                    FesabilityComments          = null,
                    FesabilityCompletetd        = false,
                    FesabilityDeliverables      = null,
                    FesabilityEnd               = model.FesabilityEndDate,
                    FiscalYearStart             = Convert2FiscalYear(model.StartDate),
                    FundingType                 = model.FundingType,
                    ImpactedDepartment          = model.ImpactedDepartment,
                    LeadingDepartment           = model.LeadingDepartment,
                    MetSuccesCriteria           = false,
                    Ora                         = null,
                    OtherComments               = model.Comments,
                    PcisResource                = model.AdditionalPcisResource ?? model.PcisResource,
                    PlantAe                     = model.PlantAE,
                    PredictedEndDate            = model.PredictedEndDate,
                    PredictedEndFiscalYear      = Convert2FiscalYear(model.PredictedEndDate),
                    Priority                    = model.Priority,
                    ProjectLeader               = (await _userManager.FindByNameAsync(User.Identity.Name)).Fullname,
                    ProjectName                 = model.ProjectName,
                    ProjectType                 = model.ProjectType,
                    Ptresource                  = model.AdditionalPTResource ?? model.PTResource,
                    StartDate                   = model.StartDate,
                    StartupComments             = null,
                    StartupLeader               = model.AdditionalStartupLeader ?? model.StartupLeader,
                    Status                      = model.Status,
                    TeamCharter                 = model.TeamCharter
                };
                ctx.Masterplan.Add(project2Add);
                ctx.SaveChanges();

                return(RedirectToAction("ViewProjects", "Project", new { message = "Project succesfully added!" }));
            }

            return(View(model));
        }