public async Task <bool> SaveTeacher(TeacherEditViewModel teacherToSave)
        {
            if (teacherToSave != null)
            {
                var teacher = new Teacher()
                {
                    Name         = teacherToSave.TeacherName,
                    Surname      = teacherToSave.TeacherSurname,
                    DepartmentId = Guid.Parse(teacherToSave.SelectedDepartment)
                };

                //        teacher.Faculty = await _requestSender.GetContetFromRequestAsyncAs<Faculty>(
                //await _requestSender.SendGetRequestAsync("https://localhost:44389/api/Faculties/one?id=" + Guid.Parse(teacherToSave.SelectedFaculty))
                //);
                //        teacher.Department = await _requestSender.GetContetFromRequestAsyncAs<Department>(
                //await _requestSender.SendGetRequestAsync("https://localhost:44389/api/Departments/one?id=" + Guid.Parse(teacherToSave.SelectedDepartment))
                //);
                var response = await _requestSender.SendPostRequestAsync("https://localhost:44389/api/Teachers/create", teacher);

                return(true);
            }

            // Return false if customeredit == null or CustomerID is not a guid
            return(false);
        }
Esempio n. 2
0
        private async void StartCycleInner(string url, int count, Dictionary <string, string> parameters)
        {
            var delay   = TimeSpan.FromMilliseconds(10);
            var request = new Request
            {
                Parameters = parameters,
                Url        = url
            };

            for (int i = 0; i < count; i++)
            {
                Response response = await _requestSender.SendPostRequestAsync(request);

                _listenter.OnEvent($"{i}) {response.StatusCode} - {response.ResponseContent}");
                Thread.Sleep(delay);
            }
        }