private ModulesDao GrabModuleInformationDao(Ideation obj)
        {
            ModulesDao dao = new ModulesDao
            {
                ModuleId         = obj.Id,
                OnGoing          = obj.OnGoing,
                Title            = obj.Title,
                LikeCount        = obj.LikeCount,
                FbLikeCount      = obj.FbLikeCount,
                TwitterLikeCount = obj.TwitterLikeCount,
                ShareCount       = obj.ShareCount,
                RetweetCount     = obj.RetweetCount,
                IsQuestionnaire  = obj.ModuleType == ModuleType.Questionnaire
            };

            if (obj.Tags != null)
            {
                dao.Tags = ExtensionMethods.ListToString(obj.Tags);
            }

            if (obj.Project != null)
            {
                dao.ProjectId = obj.Project.Id;
            }

            if (obj.ParentPhase != null)
            {
                dao.PhaseId = obj.ParentPhase.Id;
            }

            return(dao);
        }
예제 #2
0
        public void Delete(int id)
        {
            ModulesDao toDelete = _ctx.Modules.First(q => q.ModuleId == id);

            _ctx.Modules.Remove(toDelete);
            _ctx.SaveChanges();
        }
        public void Update(Ideation obj)
        {
            IdeationsDao newIdeation   = ConvertToDao(obj);
            IdeationsDao foundIdeation = _ctx.Ideations.FirstOrDefault(dto => dto.ModuleId == newIdeation.ModuleId);

            if (foundIdeation != null)
            {
                foundIdeation.ExtraInfo      = newIdeation.ExtraInfo;
                foundIdeation.MediaFile      = newIdeation.MediaFile;
                foundIdeation.RequiredFields = newIdeation.RequiredFields;
            }

            ModulesDao newModule   = GrabModuleInformationDao(obj);
            ModulesDao foundModule = _ctx.Modules.FirstOrDefault(dto => dto.ModuleId == newModule.ModuleId);

            if (foundModule != null)
            {
                foundModule.OnGoing          = newModule.OnGoing;
                foundModule.Title            = newModule.Title;
                foundModule.LikeCount        = newModule.LikeCount;
                foundModule.FbLikeCount      = newModule.FbLikeCount;
                foundModule.TwitterLikeCount = newModule.TwitterLikeCount;
                foundModule.ShareCount       = newModule.ShareCount;
                foundModule.RetweetCount     = newModule.RetweetCount;
                foundModule.Tags             = newModule.Tags;
            }

            if (newModule.PhaseId != foundModule.PhaseId)
            {
                foundModule.PhaseId = newModule.PhaseId;
            }

            _ctx.SaveChanges();
        }
예제 #4
0
        public Questionnaire Read(int id, bool details)
        {
            ModulesDao moduleDao = details ? _ctx.Modules.AsNoTracking().First(m => m.ModuleId == id) : _ctx.Modules.First(m => m.ModuleId == id);

            ExtensionMethods.CheckForNotFound(moduleDao, "Questionnaire", id);

            return(ConvertToDomain(moduleDao));
        }
        public Ideation ReadWithModule(int id)
        {
            Ideation   ideation = Read(id, true);
            ModulesDao dao      = _ctx.Modules.First(m => m.ModuleId == id);

            ideation = IdeationWithModules(ideation, dao);

            return(ideation);
        }
예제 #6
0
        public void DeleteTag(int moduleId, int tagId)
        {
            Questionnaire moduleWTags = Read(moduleId, false);
            ModulesDao    module      = ConvertToDao(moduleWTags);
            List <String> keptTags    = ExtensionMethods.StringToList(module.Tags);

            keptTags.RemoveAt(tagId - 1);
            module.Tags = ExtensionMethods.ListToString(keptTags);
            _ctx.SaveChanges();
        }
예제 #7
0
        public string CreateTag(string obj, int moduleId)
        {
            Questionnaire moduleWTags = Read(moduleId, false);
            ModulesDao    module      = ConvertToDao(moduleWTags);

            module.Tags += "," + obj;
            _ctx.SaveChanges();

            return(obj);
        }
        public void DeleteTag(int moduleId, int tagId)
        {
            Ideation      ideationWTags = Read(moduleId, false);
            ModulesDao    module        = GrabModuleInformationDao(ideationWTags);
            List <String> keptTags      = ExtensionMethods.StringToList(module.Tags);

            keptTags.RemoveAt(tagId - 1);
            module.Tags = ExtensionMethods.ListToString(keptTags);
            _ctx.SaveChanges();
        }
        public void Delete(int id)
        {
            ModulesDao toDeleteModule = _ctx.Modules.First(r => r.ModuleId == id);

            _ctx.Modules.Remove(toDeleteModule);
            IdeationsDao toDelete = _ctx.Ideations.First(r => r.ModuleId == id);

            _ctx.Ideations.Remove(toDelete);
            _ctx.SaveChanges();
        }
예제 #10
0
 private Questionnaire ConvertToDomain(ModulesDao module)
 {
     return(new Questionnaire
     {
         Id = module.ModuleId,
         Project = new Project {
             Id = module.ProjectId
         },
         ParentPhase = new Phase {
             Id = module.PhaseId
         },
         Title = module.Title,
         OnGoing = module.OnGoing,
         LikeCount = module.LikeCount,
         FbLikeCount = module.FbLikeCount,
         TwitterLikeCount = module.TwitterLikeCount,
         ShareCount = module.ShareCount,
         RetweetCount = module.RetweetCount,
         Tags = ExtensionMethods.StringToList(module.Tags),
     });
 }
        public Ideation Create(Ideation obj)
        {
            IEnumerable <Ideation> ideations = ReadAll(obj.Project.Id);

            foreach (Ideation i in ideations)
            {
                if (obj.ParentPhase.Id == i.ParentPhase.Id)
                {
                    throw new DuplicateNameException("Ideation(ID=" + obj.Id + ") heeft dezelfde parentPhase als Ideation(ID=" + i.Id + "). De phaseID is "
                                                     + obj.ParentPhase.Id + ".");
                }
            }

            obj.Id = FindNextAvailableIdeationId();
            ModulesDao   newModule   = GrabModuleInformationDao(obj);
            IdeationsDao newIdeation = ConvertToDao(obj);

            _ctx.Modules.Add(newModule);
            _ctx.Ideations.Add(newIdeation);
            _ctx.SaveChanges();

            return(obj);
        }
        private Ideation IdeationWithModules(Ideation ideation, ModulesDao dao)
        {
            ideation.Project = new Project {
                Id = dao.ProjectId
            };
            ideation.ParentPhase = new Phase {
                Id = dao.PhaseId
            };
            ideation.Title            = dao.Title;
            ideation.OnGoing          = dao.OnGoing;
            ideation.LikeCount        = dao.LikeCount;
            ideation.FbLikeCount      = dao.FbLikeCount;
            ideation.TwitterLikeCount = dao.TwitterLikeCount;
            ideation.ShareCount       = dao.ShareCount;
            ideation.RetweetCount     = dao.RetweetCount;
            ideation.Tags             = new List <string>();

            if (dao.Tags != null)
            {
                ideation.Tags = ExtensionMethods.StringToList(dao.Tags);
            }
            return(ideation);
        }
예제 #13
0
        public void Update(Questionnaire obj)
        {
            ModulesDao newModule   = ConvertToDao(obj);
            ModulesDao foundModule = _ctx.Modules.First(q => q.ModuleId == obj.Id);

            if (foundModule != null)
            {
                foundModule.OnGoing          = newModule.OnGoing;
                foundModule.LikeCount        = newModule.LikeCount;
                foundModule.Title            = newModule.Title;
                foundModule.FbLikeCount      = newModule.FbLikeCount;
                foundModule.TwitterLikeCount = newModule.TwitterLikeCount;
                foundModule.ShareCount       = newModule.ShareCount;
                foundModule.RetweetCount     = newModule.RetweetCount;
                foundModule.Tags             = newModule.Tags;
            }

            if (newModule.PhaseId != foundModule.PhaseId)
            {
                foundModule.PhaseId = newModule.PhaseId;
            }

            _ctx.SaveChanges();
        }