public async Task <ActionResult <List <ReleaseNoteViewModel> > > UpdateReleaseNote(
     ReleaseNoteSaveRequest saveRequest, Guid releaseId, Guid releaseNoteId)
 {
     return(await _releaseNoteService
            .UpdateReleaseNoteAsync(releaseId, releaseNoteId, saveRequest)
            .HandleFailuresOrOk());
 }
        public Task <Either <ActionResult, List <ReleaseNoteViewModel> > > UpdateReleaseNoteAsync(Guid releaseId,
                                                                                                  Guid releaseNoteId, ReleaseNoteSaveRequest saveRequest)
        {
            return(_persistenceHelper
                   .CheckEntityExists <Release>(releaseId, HydrateReleaseForUpdates)
                   .OnSuccess(_userService.CheckCanUpdateRelease)
                   .OnSuccess(async release =>
            {
                var releaseNote = release
                                  .Updates
                                  .First(note => note.Id == releaseNoteId);

                if (releaseNote == null)
                {
                    return NotFound <List <ReleaseNoteViewModel> >();
                }

                releaseNote.On = saveRequest.On ?? DateTime.Now;
                releaseNote.Reason = saveRequest.Reason;

                _context.Update.Update(releaseNote);
                await _context.SaveChangesAsync();
                return GetReleaseNoteViewModels(release.Id);
            }));
        }
 public async Task <ActionResult <List <ReleaseNoteViewModel> > > AddReleaseNote(ReleaseNoteSaveRequest saveRequest,
                                                                                 Guid releaseId)
 {
     return(await _releaseNoteService
            .AddReleaseNoteAsync(releaseId, saveRequest)
            .HandleFailuresOr(result => Created(HttpContext.Request.Path, result)));
 }
        public Task <Either <ActionResult, List <ReleaseNoteViewModel> > > AddReleaseNoteAsync(Guid releaseId,
                                                                                               ReleaseNoteSaveRequest saveRequest)
        {
            return(_persistenceHelper
                   .CheckEntityExists <Release>(releaseId, HydrateReleaseForUpdates)
                   .OnSuccess(_userService.CheckCanUpdateRelease)
                   .OnSuccess(async release =>
            {
                _context.Update.Add(new Update
                {
                    On = saveRequest.On ?? DateTime.Now,
                    Reason = saveRequest.Reason,
                    ReleaseId = release.Id,
                    Created = DateTime.UtcNow,
                    CreatedById = _userService.GetUserId(),
                });

                await _context.SaveChangesAsync();
                return GetReleaseNoteViewModels(release.Id);
            }));
        }