public async Task <IActionResult> AddReminder([FromBody] Reminder model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    var reminderId = await reminderRepository.AddReminder(model);

                    if (reminderId > 0)
                    {
                        return(Ok(reminderId));
                    }
                    else
                    {
                        return(NotFound());
                    }
                }
                catch (Exception)
                {
                    return(BadRequest());
                }
            }

            return(BadRequest());
        }
Ejemplo n.º 2
0
        public async Task <Reminder> AddReminder(Reminder reminder)
        {
            var _reminder = await repository.GetReminderByNewsId(reminder.NewsId);

            if (_reminder == null)
            {
                return(await repository.AddReminder(reminder));
            }
            else
            {
                throw new ReminderAlreadyExistsException($"This news: {reminder.NewsId} already have a reminder");
            }
        }