public static TagDTO ConvertTagEntitytoDTO(TagEF EFTag) { TagDTO DTOTag = new TagDTO { TagId = EFTag.TagId, Description = EFTag.Description, IsArchived = EFTag.IsArchived, CreateDate = EFTag.CreateDate }; return(DTOTag); }
public static TagEF ConvertTagDTOtoEntity(TagDTO DTOTag) { TagEF EFTag = new TagEF { TagId = DTOTag.TagId, Description = DTOTag.Description, IsArchived = DTOTag.IsArchived, CreateDate = DTOTag.CreateDate }; return(EFTag); }
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(); } } }
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(); } } }