private async Task <Course> GetCourseByCourseViewModel(CourseViewModel courseViewModel) { IList <Tag> tagList = new List <Tag>(); //Todo: need to move this to View model converter factory Course course = new Course() { Author = courseViewModel.Author, Description = courseViewModel.Description, StartedDateTime = courseViewModel.StartedDateTime, EndDateTime = courseViewModel.EndDateTime, Precentage = courseViewModel.Precentage, Name = courseViewModel.Name, CourseStatus = courseViewModel.CourseStatus, Tags = tagList, CourseId = courseViewModel.CourseId }; if (courseViewModel.Tags == "undefined") { return(course); } var tags = JsonConvert.DeserializeObject <TagViewModel[]>(courseViewModel.Tags); foreach (TagViewModel tagViewModel in tags) { string tagName = tagViewModel.Text; Tag dbTag = _tagRepository.Get(s => s.TagName == tagName); if (dbTag == null) { Tag newTag = new Tag() { TagName = tagName }; //new Tag add to the database await _tagRepository.CreateAsync(newTag); tagList.Add(newTag); } else { tagList.Add(dbTag); } } return(course); }
public App() { // Nina User.CurrentUserId = 9; // TODO: implement logging InitializeComponent(); Suspending += OnSuspending; projects = new ProjectsRepository(); users = new UsersRepository(); applications = new ProjectApplicationsRepository(); // FIX Task.Run(() => TagsRepository.CreateAsync()).Wait(); tags = TagsRepository.instance; Task.Run(() => FacultiesRepository.CreateAsync()).Wait(); faculties = FacultiesRepository.instance; }