public async Task <bool> UpdateNotification(DTONotification notification) { Notification mapNotification = _mapper.Map <Notification>(notification); _notificationRepository.Update(mapNotification); bool success = true; try { await _notificationRepository.SaveChanges(); } catch { if (!_notificationRepository.NotificationExists(notification.NotificationID)) { success = false; } else { throw; } } return(success); }
public async Task <ActionResult <DTONotification> > GetNotification(int id) { DTONotification notification = await _service.GetNotification(id); if (notification == null) { return(NotFound()); } return(notification); }
public async Task <IActionResult> AddNotification(DTONotification notification) { bool success = await _service.AddNotification(notification); if (success) { return(Ok()); } else { return(BadRequest()); } }
public async Task <IActionResult> UpdateNotification(DTONotification notification) { bool success = await _service.UpdateNotification(notification); if (success) { return(Ok()); } else { return(NotFound()); } }
public async Task <bool> AddNotification(DTONotification notification) { Notification mapNotification = _mapper.Map <Notification>(notification); _notificationRepository.Add(mapNotification); bool success = true; try { await _notificationRepository.SaveChanges(); } catch { success = false; } return(success); }