Exemple #1
0
        public int? ImportProjects(ProjectMapModelMinified projectMapModel)
        {
            var matchedProjects = Sessions.ProjectMapModel.MatchedProjects;

            foreach (var mp in matchedProjects)
            {
                var v = projectMapModel.MatchedProjects.Find(f => f.iatiActivity.IatiIdentifier == mp.iatiActivity.IatiIdentifier);

                mp.Fields = v.Fields;
                mp.TransactionFields = v.TransactionFields;

            }

            //actual method starts here :)
            var margedProjects = ImportLogic.MergeProjects(matchedProjects);

            foreach (var item in Sessions.ProjectsToMap?.NewProjectsToAddInAims)
            {
                item.AllID = Sessions.DP.AllID;
                margedProjects.Add(item);

            }

            Sessions.Clear();
            return aimsDAL.UpdateProjects(margedProjects, Sessions.UserId, false);
        }
Exemple #2
0
        public bool SubmitManualMatchingUsingDropdown(ProjectMapModelMinified projectMapModel)
        {
            if (projectMapModel != null)
            {
                UpdateActivities(projectMapModel.IatiActivitiesNotInAims, Sessions.ProjectMapModel.IatiActivitiesNotInAims);

                //Sessions.ProjectMapModel.AimsProjectsNotInIati = projectMapModel.AimsProjectsNotInIati;

                Sessions.ProjectMapModel.MatchedProjects.RemoveAll(r => r.IsManuallyMapped);

            }

            //actual method starts here :)

            //add manually matched projects
            var aimsProjects = Sessions.activitiesContainer?.AimsProjects;
            var iatiActivities = Sessions.ProjectMapModel?.IatiActivitiesNotInAims;
            foreach (var project in aimsProjects)
            {
                var mappedActivityCount = iatiActivities.Count(c => c.ProjectId == project.ProjectId);
                if (mappedActivityCount == 1)
                {
                    var m = new ProjectFieldMapModel(iatiActivities.Find(c => c.ProjectId == project.ProjectId), project, false) { IsManuallyMapped = true };

                    Sessions.ProjectMapModel.MatchedProjects.Add(m);

                }
                else if (mappedActivityCount > 1)
                {
                    iatiactivity groupedActivity = MergeToSingleActivity(iatiActivities.FindAll(c => c.ProjectId == project.ProjectId));

                    Sessions.ProjectMapModel.MatchedProjects.Add(new ProjectFieldMapModel(groupedActivity, project, false) { IsManuallyMapped = true, IsGrouped = true });

                }

            }

            //foreach (var activity in Sessions.ProjectMapModel?.IatiActivitiesNotInAims.Where(w => w.ProjectId > 0))
            //{
            //    var project = aimsProjects.Find(f => f.ProjectId == activity.ProjectId);

            //    if (project != null)
            //    {
            //        Sessions.ProjectMapModel.MatchedProjects.Add(new ProjectFieldMapModel(activity, project) { IsManuallyMapped = true });
            //    }
            //}

            foreach (var activity in Sessions.ProjectMapModel?.IatiActivitiesNotInAims.Where(w => w.ProjectId == -2))
            {
                activity.IsCommitmentIncluded = true;
                activity.IsDisbursmentIncluded = true;
                activity.IsPlannedDisbursmentIncluded = true;

                Sessions.ProjectMapModel.NewProjectsToAddInAims.Add(activity);

            }

            return true;
        }