示例#1
0
        public async Task <IActionResult> createReminder(int instructorId, [FromBody] SaveReminderResource reminderResource)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            Instructor instructor = await instructorRepository.GetOne(instructorId);

            if (instructor == null)
            {
                return(NotFound());
            }

            Reminder reminder = mapper.Map <SaveReminderResource, Reminder>(reminderResource);

            reminder.InstructorId = instructorId;
            instructorRepository.AddReminder(reminder);
            await unitOfWork.CompleteAsync();

            var response = mapper.Map <Reminder, ReminderResource>(reminder);

            return(Ok(response));
        }