public async Task EditCourse(CourseFullInfoVM course) { var newCourse = new CreateCourseCommand { Title = course.Title, ImgSrc = course.ImgSrc, Description = course.Description, Difficulty = course.Difficulty }; await _httpClient.PostAsJsonAsync("https://localhost:7001/api/courses", newCourse); }
public async Task <bool> EditCourse(CourseFullInfoVM course) { if (await _localStorageService.ContainKeyAsync(key + course.Id) && await _localStorageService.ContainKeyAsync(key_all)) { var allItems = await _localStorageService.GetItemAsync <List <WorkbanchItemVM> >(key_all); var wbitem = allItems.FirstOrDefault(i => i.Id == course.Id); if (wbitem != null) { await _localStorageService.SetItemAsync(key + course.Id, course); wbitem.Title = course.Title; await _localStorageService.SetItemAsync(key_all, allItems); return(true); } } return(false); }
private CourseFullInfoVM GetExample(Guid id) { var root = new RecordVM { Id = new Guid(new byte[] { 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }), Type = RecordType.Root, Title = "ROOT" }; var chapter1 = new RecordVM { Id = new Guid(new byte[] { 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }), Type = RecordType.Group, Title = "Введение в C#" }; var article1_1 = new RecordVM { Type = RecordType.Article, Id = new Guid(new byte[] { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }), Title = "Язык C# и платформа .NET" }; var article1_2 = new RecordVM { Type = RecordType.Article, Id = new Guid(new byte[] { 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }), Title = "Начало работы с Visual Studio. Первая программа" }; var article1_3 = new RecordVM { Type = RecordType.Article, Id = new Guid(new byte[] { 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }), Title = "Компиляция в командной строке" }; var chapter2 = new RecordVM { Id = new Guid(new byte[] { 1, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }), Type = RecordType.Group, Title = "Основы программирования на C#" }; var article2_1 = new RecordVM { Type = RecordType.Article, Id = new Guid(new byte[] { 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }), Title = "Структура программы" }; var subchapter2_2 = new RecordVM { Type = RecordType.Group, Id = new Guid(new byte[] { 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }), Title = "Работа с данными" }; var article2_2_1 = new RecordVM { Type = RecordType.Article, Id = new Guid(new byte[] { 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }), Title = "Переменные" }; var article2_2_2 = new RecordVM { Type = RecordType.Article, Id = new Guid(new byte[] { 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }), Title = "Литералы" }; var article2_2_3 = new RecordVM { Type = RecordType.Article, Id = new Guid(new byte[] { 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }), Title = "Типы данных" }; var article2_3 = new RecordVM { Type = RecordType.Article, Id = new Guid(new byte[] { 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }), Title = "Консольный ввод-вывод" }; var subchapter2_4 = new RecordVM { Type = RecordType.Group, Id = new Guid(new byte[] { 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }), Title = "Операции с данными" }; var article2_4_1 = new RecordVM { Type = RecordType.Article, Id = new Guid(new byte[] { 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }), Title = "Арифметические операции" }; var article2_4_2 = new RecordVM { Type = RecordType.Article, Id = new Guid(new byte[] { 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }), Title = "Поразрядные операции" }; var article2_4_3 = new RecordVM { Type = RecordType.Article, Id = new Guid(new byte[] { 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }), Title = "Операции присваивания" }; var article2_4_4 = new RecordVM { Type = RecordType.Article, Id = new Guid(new byte[] { 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }), Title = "Преобразование базовых типов данных" }; root.Children = new() { chapter1, chapter2 }; chapter1.Children = new() { article1_1, article1_2, article1_3 }; chapter2.Children = new() { article2_1, subchapter2_2, article2_3, subchapter2_4 }; subchapter2_2.Children = new() { article2_2_1, article2_2_2, article2_2_3 }; subchapter2_4.Children = new() { article2_4_1, article2_4_2, article2_4_3, article2_4_4 }; var course = new CourseFullInfoVM() { Id = id, Title = "Основы C#", Description = "Курс рассчитан на людей с минимальным опытом программирования и знакомит с основами синтаксиса C#" + " и стандартными классами .NET, с основами ООП и базовыми алгоритмами.", //ImgSrc = "https://avatars.mds.yandex.net/get-zen_doc/4423710/pub_608fda25a38d215d4e183cba_60928147de56f009bc84b924/scale_1200", Difficulty = Difficulty.Beginer, Rating = new RatingModel { Rating = 4.5, VotersCount = 108 }, RootRecord = root }; return(course); }