Beispiel #1
0
        public async Task <bool> CreateRaiderNoteAsync(RaiderNote note)
        {
            await _context.RaiderNotesDto.AddAsync(_mapper.Map <RaiderNoteDto>(note));

            var created = await _context.SaveChangesAsync();

            return(created > 0);
        }
Beispiel #2
0
        public async Task <IActionResult> Create([FromBody] CreateRaiderNoteRequest raiderNoteRequest)
        {
            //var raider = await _raiderService.GetRaiderByIdAsync(raiderNoteRequest.RaiderId);

            //if (raider is null)
            //    return BadRequest("Cannot create note for raider, because it does not exists.");

            var rosterAccess = await _rosterAccessService.GetRosterAccessAsync(GetBy.RaiderId, HttpContext.GetUserId(), raiderNoteRequest.RaiderId);

            if (rosterAccess is null)
            {
                return(Forbid());
            }

            if (!rosterAccess.IsOwner)
            {
                if (!rosterAccess.IsModerator)
                {
                    return(Forbid());
                }
            }

            var raiderNoteId = Guid.NewGuid().ToString();

            var raiderNote = new RaiderNote
            {
                RaiderId     = raiderNoteRequest.RaiderId,
                RaiderNoteId = raiderNoteId,
                Message      = raiderNoteRequest.Message,
                CreatorId    = rosterAccess.UserId
            };

            await _raiderNoteService.CreateRaiderNoteAsync(raiderNote);

            var uri = _uriService.GetRaiderNoteUri(raiderNote.RaiderNoteId);

            return(Created(uri, _mapper.Map <RaiderNoteResponse>(raiderNote)));
        }
Beispiel #3
0
 public async Task <bool> UpdateRaiderNoteAsync(RaiderNote note)
 {
     _context.RaiderNotesDto.Update(_mapper.Map <RaiderNoteDto>(note));
     return(await _context.SaveChangesAsync() > 0);
 }