public async Task <IActionResult> Put(int id, UpdateNotificationCommand data) { data.Data.Attributes.notification_id = id; var result = await _mediatr.Send(data); return(Ok(result)); }
public async Task <UpdateNotificationValidationResult> Validate(UpdateNotificationCommand command, string subject) { if (command == null) { throw new ArgumentNullException(nameof(command)); } if (string.IsNullOrWhiteSpace(subject)) { throw new ArgumentNullException(nameof(subject)); } var record = await _notificationRepository.Get(command.Id); if (record == null) { return(new UpdateNotificationValidationResult(ErrorDescriptions.TheNotificationDoesntExist)); } if (record.To != subject) { return(new UpdateNotificationValidationResult(ErrorDescriptions.TheNotificationCannotBeUpdated)); } return(new UpdateNotificationValidationResult(record)); }
public async Task <IActionResult> Update(int Id, [FromBody] UpdateNotificationCommand payload) { return(Ok(await _mediator.Send(new UpdateNotificationCommand() { id = Id, data = payload.data }))); }
public async Task <IActionResult> Execute(JObject jObj, string id, string subject, string commonId) { if (jObj == null) { throw new ArgumentNullException(nameof(jObj)); } if (string.IsNullOrWhiteSpace(id)) { throw new ArgumentNullException(nameof(id)); } if (string.IsNullOrWhiteSpace(subject)) { throw new ArgumentNullException(nameof(subject)); } UpdateNotificationCommand command = null; try { command = _requestBuilder.GetUpdateNotification(jObj); } catch (ArgumentException ex) { var error = _responseBuilder.GetError(ErrorCodes.Request, ex.Message); return(_controllerHelper.BuildResponse(HttpStatusCode.BadRequest, error)); } command.Id = id; command.CommonId = commonId; var validationResult = await _updateNotificationValidator.Validate(command, subject); if (!validationResult.IsValid) { var error = _responseBuilder.GetError(ErrorCodes.Request, validationResult.Message); return(_controllerHelper.BuildResponse(HttpStatusCode.BadRequest, error)); } _commandSender.Send(command); return(new OkResult()); }
public async Task <IActionResult> UpdateNotif(int id, UpdateNotificationCommand yo) { yo.Data.Attributes.Notification_Id = id; return(Ok(await _mediatr.Send(yo))); }
public async Task <IActionResult> UpdateNotification([FromBody] UpdateNotificationCommand command) { var result = await Mediator.Send(command); return(result.Successful == true?Ok(result) : BadRequest(result.Exception.InnerException.Message ?? result.Exception.Message)); }