public async Task <IHttpActionResult> Get(Guid MBID) { try { var artistInfo = await _artistInfoProvider.GetArtistInfoAsync(MBID); var model = new ArtistInfoModel() { Id = MBID, Description = artistInfo.Description, Albums = artistInfo.ReleaseGroups.Where(x => x.PrimaryType == "Album").Select(x => new Album() { Id = x.Id, Title = x.Title, Image = x.CovertArtUrl }).ToList() }; return(Ok(model)); } catch (ArtistInfoNotFoundException) { return(NotFound()); } catch (Exception) { return(InternalServerError()); } }
public ActionResult ArtistInfo() { ArtistInfoModel model = new ArtistInfoModel(); int artistId = WebSecurity.CurrentUserId; try { var userDataCollection = from d in m_context.Artists where d.ArtistId == artistId select new { d.CreateDate, d.LastActivityDate, d.ProfileViews, d.Tasks, d.UserName, d.ProfileLastViewDate, d.AvatarURL }; var userData = userDataCollection.FirstOrDefault(); if (userData != null) { model.AccountCreatedDate = userData.CreateDate; model.ArtistName = userData.UserName; model.ProfileLastViewedDate = userData.ProfileLastViewDate.Value; model.ProfileBookmark = string.Concat(SharedConfig.ApplicationURL, "/", userData.UserName); model.ProfileViews = userData.ProfileViews; model.AvatarURL = userData.AvatarURL; model.PasswordLastChangedDate = WebSecurity.GetPasswordChangedDate(WebSecurity.CurrentUserName); } else { return(PartialView("_NoDataPartial", "Artist not found.")); } } catch (Exception) { //TODO: Log exception return(PartialView("_NoDataPartial", "Error occured.")); } return(PartialView("_ArtistInfoPartial", model)); }