示例#1
0
        public async Task <IActionResult> Post(SongReactionCreateModel model)
        {
            var userId = this.userManager.GetUserId(this.User);

            await this.songReactionService.Create(model, userId);

            return(this.Ok());
        }
        public async Task Update(SongReactionCreateModel model, string id)
        {
            var songReaction = this.context.SongReactions.Find(id);

            songReaction.Reaction = model.Reaction;

            this.context.SongReactions.Update(songReaction);
            await this.context.SaveChangesAsync();
        }
        public async Task Create(SongReactionCreateModel model, string userId)
        {
            var songReaction = model.To <SongReaction>();

            songReaction.UserId = userId;
            songReaction.SongId = model.SongId;
            await this.context.SongReactions.AddAsync(songReaction);

            await this.context.SaveChangesAsync();
        }
示例#4
0
        public async Task <IActionResult> Put(string id, SongReactionCreateModel model)
        {
            if (!this.ModelState.IsValid)
            {
                return(this.BadRequest());
            }

            await this.songReactionService.Update(model, id);

            return(this.Ok());
        }