Ejemplo n.º 1
0
        public async Task <IActionResult> PutLessonLearned(int id, LessonLearned lessonLearned)
        {
            if (id != lessonLearned.LessonLearnedId)
            {
                return(BadRequest());
            }

            _context.Entry(lessonLearned).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!LessonLearnedExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(Ok(lessonLearned));
        }
Ejemplo n.º 2
0
        public async Task <ActionResult <LessonLearned> > PostLessonLearned(LessonLearned lessonLearned)
        {
            _context.LessonLearned.Add(lessonLearned);

            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetLessonLearned", new { id = lessonLearned.LessonLearnedId }, lessonLearned));
        }
Ejemplo n.º 3
0
        public async Task <ActionResult <Project> > UpdateProject(int id, CreateProject createProject)
        {
            if (id != createProject.ProjectId)
            {
                return(BadRequest());
            }

            var project = _context.Project.Find(id);

            if (project == null)
            {
                return(NotFound());
            }

            // Closing Form
            if (createProject.ProjectDescription != null)
            {
                project.ProjectDescription = createProject.ProjectDescription;
                project.ScopeStatement     = createProject.ScopeStatement;

                History history = new History
                {
                    ProjectId    = id,
                    UserId       = createProject.UserId,
                    StatusBefore = project.ProjectStatus,
                    StatusAfter  = createProject.ProjectStatus,
                    Comment      = createProject.Comment
                };
                _context.History.Add(history);
                project.ProjectStatus = createProject.ProjectStatus;

                foreach (var x in createProject.Milestone)
                {
                    Milestone milestone = new Milestone
                    {
                        ProjectId            = createProject.ProjectId,
                        ProjectCategoryId    = 4,
                        MilestoneDescription = x.MilestoneDescription,
                        EstimatedEndTime     = x.EstimatedEndTime,
                        CompletedTime        = x.CompletedTime,
                    };
                    _context.Milestone.Add(milestone);
                }

                foreach (var x in createProject.LessonLearned)
                {
                    LessonLearned lessonLearned = new LessonLearned
                    {
                        ProjectId         = createProject.ProjectId,
                        LLCategoryId      = x.LLCategoryId,
                        UserId            = x.UserId,
                        ProjectCategoryId = 4, // 4=closing
                        Title             = x.Title,
                        Impact            = x.Impact,
                        LessonLearnedText = x.LessonLearnedText,
                        Recommendation    = x.Recommendation,
                    };
                    _context.LessonLearned.Add(lessonLearned);
                }
            }
            // Planning Form
            else if (createProject.ProjectManagementPlan != null)
            {
                History history = new History
                {
                    ProjectId    = id,
                    UserId       = createProject.UserId,
                    StatusBefore = project.ProjectStatus,
                    StatusAfter  = createProject.ProjectStatus,
                    Comment      = createProject.Comment
                };
                _context.History.Add(history);

                project.ProjectStatus         = createProject.ProjectStatus;
                project.ProjectManagementPlan = createProject.ProjectManagementPlan;
                project.ExecutiveSummaryOfProjectInitiative = createProject.ExecutiveSummaryOfProjectInitiative;
                project.Assumption = createProject.Assumption;
                project.ChangeControlManagement    = createProject.ChangeControlManagement;
                project.ScheduleAndTimeDescription = createProject.ScheduleAndTimeDescription;
            }
            // Initiating Form
            else
            {
                project.ProjectStatus         = createProject.ProjectStatus;
                project.InitiativeTitle       = createProject.InitiativeTitle;
                project.PreparedDate          = createProject.PreparedDate;
                project.BackgroundInformation = createProject.BackgroundInformation;
                project.ObjectiveBenefit      = createProject.ObjectiveBenefit;
                project.LandCompensation      = createProject.LandCompensation;
                project.LandImprovement       = createProject.LandImprovement;
                project.Building                = createProject.Building;
                project.Infrastructure          = createProject.Infrastructure;
                project.PlantMachine            = createProject.PlantMachine;
                project.Equipment               = createProject.Equipment;
                project.ExpenseUnderDevelopment = createProject.ExpenseUnderDevelopment;
                project.WorkingCapital          = createProject.WorkingCapital;
                project.Contingency             = createProject.Contingency;
                project.Total             = createProject.Total;
                project.Timeline          = createProject.Timeline;
                project.RequestedBy       = createProject.RequestedBy;
                project.AcknowledgedBy    = createProject.AcknowledgedBy;
                project.AgreedBy          = createProject.AgreedBy;
                project.ExecutiveSummary  = createProject.ExecutiveSummary;
                project.ProjectDefinition = createProject.ProjectDefinition;
                project.Vision            = createProject.Vision;
                project.Objective         = createProject.Objective;

                var assigned = _context.Assign.Where(a => a.ProjectId == id).ToList();
                foreach (var x in assigned)
                {
                    _context.Assign.Remove(x);
                }

                foreach (var a in createProject.Users)
                {
                    foreach (var b in a.UserId)
                    {
                        Assign assign = new Assign
                        {
                            ProjectId = project.ProjectId,
                            RoleId    = a.RoleId,
                            UserId    = b
                        };
                        _context.Assign.Add(assign);
                    }
                }
            }//end of else

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ProjectExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(Ok(project));
        }