From f2235b649d15d0144e40fab2b5407e92dd9d3efb Mon Sep 17 00:00:00 2001
From: Lucca Santangelo <luccasant95@gmail.com>
Date: Sat, 12 Dec 2020 17:30:40 -0300
Subject: [PATCH] fix bedelia

---
 Tsi1.Api/Tsi1.BusinessLayer/DataLoad/DataLoad.cs      |  9 ++-------
 .../Tsi1.BusinessLayer/Dtos/CourseCreateBedeliaDto.cs | 11 -----------
 .../Tsi1.BusinessLayer/Interfaces/IBedeliaService.cs  |  2 +-
 .../Tsi1.BusinessLayer/Services/BedeliaService.cs     |  8 ++++----
 4 files changed, 7 insertions(+), 23 deletions(-)
 delete mode 100644 Tsi1.Api/Tsi1.BusinessLayer/Dtos/CourseCreateBedeliaDto.cs

diff --git a/Tsi1.Api/Tsi1.BusinessLayer/DataLoad/DataLoad.cs b/Tsi1.Api/Tsi1.BusinessLayer/DataLoad/DataLoad.cs
index ff63b39..f75862f 100644
--- a/Tsi1.Api/Tsi1.BusinessLayer/DataLoad/DataLoad.cs
+++ b/Tsi1.Api/Tsi1.BusinessLayer/DataLoad/DataLoad.cs
@@ -56,14 +56,9 @@ namespace Tsi1.BusinessLayer.DataLoad
 
         public async Task<ServiceResult<bool>> LoadCoursesInBedelia()
         {
-            var courses = await _context.Courses.Select(x => 
-                new CourseCreateBedeliaDto()
-                {
-                    Name = x.Name
-                })
-                .ToListAsync();
+            var courseNames = await _context.Courses.Select(x => x.Name).ToListAsync();
 
-            return await _bedeliaService.CreateCourses(courses);
+            return await _bedeliaService.CreateCourses(courseNames);
         }
 
         public async Task LoadDataAsync()
diff --git a/Tsi1.Api/Tsi1.BusinessLayer/Dtos/CourseCreateBedeliaDto.cs b/Tsi1.Api/Tsi1.BusinessLayer/Dtos/CourseCreateBedeliaDto.cs
deleted file mode 100644
index 5897c34..0000000
--- a/Tsi1.Api/Tsi1.BusinessLayer/Dtos/CourseCreateBedeliaDto.cs
+++ /dev/null
@@ -1,11 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tsi1.BusinessLayer.Dtos
-{
-    public class CourseCreateBedeliaDto
-    {
-        public string Name { get; set; }
-    }
-}
diff --git a/Tsi1.Api/Tsi1.BusinessLayer/Interfaces/IBedeliaService.cs b/Tsi1.Api/Tsi1.BusinessLayer/Interfaces/IBedeliaService.cs
index 1a159db..63e4db8 100644
--- a/Tsi1.Api/Tsi1.BusinessLayer/Interfaces/IBedeliaService.cs
+++ b/Tsi1.Api/Tsi1.BusinessLayer/Interfaces/IBedeliaService.cs
@@ -15,6 +15,6 @@ namespace Tsi1.BusinessLayer.Interfaces
         Task<ServiceResult<bool>> Login(string identityCard, string password);
         Task<ServiceResult<bool>> IsValidCourse(string courseName);
         Task<ServiceResult<bool>> CreateUsers(List<UserCreateBedeliaDto> users);
-        Task<ServiceResult<bool>> CreateCourses(List<CourseCreateBedeliaDto> users);
+        Task<ServiceResult<bool>> CreateCourses(List<string> courseNames);
     }
 }
diff --git a/Tsi1.Api/Tsi1.BusinessLayer/Services/BedeliaService.cs b/Tsi1.Api/Tsi1.BusinessLayer/Services/BedeliaService.cs
index 9453105..da77b6f 100644
--- a/Tsi1.Api/Tsi1.BusinessLayer/Services/BedeliaService.cs
+++ b/Tsi1.Api/Tsi1.BusinessLayer/Services/BedeliaService.cs
@@ -104,7 +104,7 @@ namespace Tsi1.BusinessLayer.Services
             var jsonInString = JsonConvert.SerializeObject(users);
             var model = new StringContent(jsonInString, Encoding.UTF8, "application/json");
 
-            var response = await _httpClient.PostAsync("api/Users", model);
+            var response = await _httpClient.PostAsync("api/Users/loadData", model);
             if (response.StatusCode != HttpStatusCode.OK)
             {
                 result.HasError = true;
@@ -115,14 +115,14 @@ namespace Tsi1.BusinessLayer.Services
             return result;
         }
 
-        public async Task<ServiceResult<bool>> CreateCourses(List<CourseCreateBedeliaDto> courses)
+        public async Task<ServiceResult<bool>> CreateCourses(List<string> courseNames)
         {
             var result = new ServiceResult<bool>();
 
-            var jsonInString = JsonConvert.SerializeObject(courses);
+            var jsonInString = JsonConvert.SerializeObject(courseNames);
             var model = new StringContent(jsonInString, Encoding.UTF8, "application/json");
 
-            var response = await _httpClient.PostAsync("api/Courses", model);
+            var response = await _httpClient.PostAsync("api/Courses/loadData", model);
             if (response.StatusCode != HttpStatusCode.OK)
             {
                 result.HasError = true;
-- 
GitLab