Blog.Web.Api.Controllers.AlbumController.GetByUser C# (CSharp) Method

GetByUser() private method

private GetByUser ( string username, string albumName ) : IHttpActionResult
username string
albumName string
return IHttpActionResult
        public IHttpActionResult GetByUser(string username, string albumName)
        {
            try
            {
                var user = _usersService.GetByUserName(username);
                if (user == null) return Ok(new Album().GenerateError<Album>((int)Constants.Error.RecordNotFound, "User not found!"));

                var albumList = _service.GetByUser(user.Id);

                if (albumList == null || albumList.Count == 0)
                {
                    return Ok(new Album().GenerateError<Album>((int)Constants.Error.RecordNotFound, "Album not found!"));
                }
                
                var albumByName = albumList.First(a => a.AlbumName == albumName);

                return Ok(albumByName ?? new Album().GenerateError<Album>((int)Constants.Error.RecordNotFound, "Album not found!"));
            }
            catch (Exception ex)
            {
                _errorSignaler.SignalFromCurrentContext(ex);
                return BadRequest();
            }
        }

Same methods

AlbumController::GetByUser ( int userId ) : IHttpActionResult