private void AddLecturerComplete(object obj)
        {
            User user = new User {
                Name     = this.Name,
                Password = this.Password,
                Email    = this.Email,
                Phone    = this.Phone,
                Image    = "https://via.placeholder.com/150",
            };

            Lecturer lecturer = new Lecturer {
                Faculty = this.Faculty,
                User    = user,
            };

            List <Course> list = new List <Course>();

            foreach (var c in SelectedOfferedCourseItem)
            {
                list.Add(
                    new Course {
                    Id         = c.Id,
                    CourseName = c.Name,
                    CourseCode = c.CourseCode
                }
                    );
            }

            _lecturserService.CreateLecturer(lecturer, list).ContinueWith(task => {
                if (task.Result == LecturerRegistrationResult.Success)
                {
                    Name     = "";
                    Password = "";
                    Email    = "";
                    Phone    = "";
                    Faculty  = "";

                    MessageBox.Show("Lecturer Added", "Action Successfull", MessageBoxButton.OK, MessageBoxImage.Information);

                    OnPropertyChanged(nameof(Name));
                    OnPropertyChanged(nameof(Password));
                    OnPropertyChanged(nameof(Email));
                    OnPropertyChanged(nameof(Phone));
                    OnPropertyChanged(nameof(Faculty));
                }
                else if (task.Result == LecturerRegistrationResult.EmailAlreadyExists)
                {
                    MessageBox.Show("Lecturer Email Already Exsist", "Action Successfull", MessageBoxButton.OK, MessageBoxImage.Error);
                }
                else if (task.Result == LecturerRegistrationResult.ZeroCourseFound)
                {
                    MessageBox.Show("Lecturer Does not have any course", "Action Successfull", MessageBoxButton.OK, MessageBoxImage.Error);
                }
                else
                {
                    MessageBox.Show("Unknown Error", "Action Successfull", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            });
        }
        public async Task <ActionResult <LecturerResource> > CreateLecturer([FromBody] SaveLecturerResource saveLecturerResource)
        {
            var validator        = new SaveLecturerResourceValidator();
            var validationResult = await validator.ValidateAsync(saveLecturerResource);

            if (!validationResult.IsValid)
            {
                _logger.LogError(DateTime.Now + $"\nCreating lecturer failed, validation isn't valid " + validationResult.Errors.ToString());
                return(BadRequest(validationResult.Errors));
            }

            var lecturerToCreate = _mapper.Map <SaveLecturerResource, Lecturer>(saveLecturerResource);

            var result = await _lecturerService.CreateLecturer(lecturerToCreate);

            var createdLecturer = _mapper.Map <Lecturer, LecturerResource>(result);

            return(Ok(result));
        }
        public async Task <IActionResult> Post([FromBody] CreateLecturerDto createLecturerDto)
        {
            try
            {
                bool mock = true; // change this to false to remove the mock

                if (!mock)
                {
                    _lecturerService.CreateLecturer(createLecturerDto);

                    return(Ok());
                }

                return(Ok());
            }
            catch (Exception e)
            {
                return(BadRequest(e));
            }
        }
 public async Task <IActionResult> Post([FromBody] LecturerDto createLecturerDto)
 {
     return(Ok(await _service.CreateLecturer(createLecturerDto)));
 }