Пример #1
0
        public async Task <IActionResult> Delete([FromBody] MiniTag value)
        {
            //TODO: Propagate deletion to paired tags. Possibly with a new state for "Autoadded"
            MiniTag MiniTag = await _context.MiniTag.FindAsync(value.Mini.ID, value.Tag.ID);

            if (User.IsInRole("Moderator"))
            {
                _context.Remove(MiniTag);
            }
            else
            {
                MiniTag.Status                 = Status.Deleted;
                MiniTag.LastModifiedTime       = DateTime.Now;
                _context.Attach(MiniTag).State = EntityState.Modified;
            }

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                return(Conflict());
            }
            return(Ok("{}"));
        }
Пример #2
0
        public async Task <IActionResult> Post([FromBody] MiniTag value)
        {
            IdentityUser user = await _userManager.GetUserAsync(User);

            MiniTag newMT = await _mediator.Send(new MiniTagSubmissionRequest(value.Mini, value.Tag, user));

            return(Ok("{}"));
        }
Пример #3
0
        public async Task <IActionResult> Patch([FromBody] MiniTag value)
        {
            MiniTag MiniTag = await _context.MiniTag.FindAsync(value.MiniID, value.TagID);

            if (MiniTag == null)
            {
                return(NotFound());
            }

            MiniTag.Status                 = value.Status;
            MiniTag.LastModifiedTime       = DateTime.Now;
            _context.Attach(MiniTag).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                return(Conflict());
            }

            return(Ok("{}"));
        }