Example #1
0
        public static TagDTO ConvertTagEntitytoDTO(TagEF EFTag)
        {
            TagDTO DTOTag = new TagDTO
            {
                TagId       = EFTag.TagId,
                Description = EFTag.Description,
                IsArchived  = EFTag.IsArchived,
                CreateDate  = EFTag.CreateDate
            };

            return(DTOTag);
        }
Example #2
0
        public static TagEF ConvertTagDTOtoEntity(TagDTO DTOTag)
        {
            TagEF EFTag = new TagEF
            {
                TagId       = DTOTag.TagId,
                Description = DTOTag.Description,
                IsArchived  = DTOTag.IsArchived,
                CreateDate  = DTOTag.CreateDate
            };

            return(EFTag);
        }
Example #3
0
        public void AddTag(TagDTO tagDTO)
        {
            TagEF tagEF = DataConverter.ConvertTagDTOtoEntity(tagDTO);

            using (var context = new DemoContext())
            {
                if (ValidateUnique(tagEF.Description) == true)
                {
                    context.Tags.Add(tagEF);
                    context.SaveChanges();
                }
            }
        }
Example #4
0
        public void AssignTagtoTask(int taskid, int tagid)
        {
            using (var context = new DemoContext())
            {
                TagEF  tagtoadd = context.Tags.Find(tagid);
                TaskEF task     = context.Tasks.Find(taskid);

                if ((tagtoadd != null) && (CountTags(taskid) < 10) && (tagtoadd.IsArchived == false))
                {
                    task.Tags.Add(tagtoadd);
                    tagtoadd.Tasks.Add(task);
                    context.SaveChanges();
                }
            }
        }