예제 #1
0
        public async Task <IActionResult> Update(models.Artist artist)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var result = await ArtistService.UpdateArtist(await UserManager.GetUserAsync(User).ConfigureAwait(false), artist).ConfigureAwait(false);

            if (result?.IsNotFoundResult != false)
            {
                return(NotFound());
            }
            if (!result.IsSuccess)
            {
                if (result.IsAccessDeniedResult)
                {
                    return(StatusCode((int)HttpStatusCode.Forbidden));
                }
                if (result.Messages?.Any() ?? false)
                {
                    return(StatusCode((int)HttpStatusCode.BadRequest, result.Messages));
                }
                return(StatusCode((int)HttpStatusCode.InternalServerError));
            }
            return(Ok(result));
        }
예제 #2
0
        public async Task <IActionResult> Update(models.Artist artist)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var result = await this.ArtistService.UpdateArtist(await this.CurrentUserModel(), artist);

            if (result == null || result.IsNotFoundResult)
            {
                return(NotFound());
            }
            if (!result.IsSuccess)
            {
                return(StatusCode((int)HttpStatusCode.InternalServerError));
            }
            return(Ok(result));
        }