コード例 #1
0
        public FollowedArtistModel GetUsersArtists(string email)
        {
            using (var context = new sparrow_dbEntities())
            {
                var user        = context.SPRW_USER.FirstOrDefault(i => i.EMAIL == email);
                var artists     = user.SPRW_ARTIST.ToList();
                var userArtists = new FollowedArtistModel
                {
                    ArtistIds     = new List <int>(),
                    LikedTrackIds = context.SPRW_TRACK_POPULAR_LIKE.Where(i => i.USER_ID == user.USER_ID).Select(i => i.TRACK_ID).ToList(),
                    Events        = new List <EventModel>(),
                    Bulliten      = new List <BullitenModel>()
                };

                foreach (var artist in artists)
                {
                    userArtists.ArtistIds.Add(artist.ARTIST_ID);
                    var bullitens = artist.ARTIST_BLOG.ToList();
                    foreach (var bulliten in bullitens)
                    {
                        var userBulliten = new BullitenModel
                        {
                            ArtistId  = artist.ARTIST_ID,
                            AristName = artist.NAME,
                            Bulliten  = bulliten.BLOG
                        };
                        userArtists.Bulliten.Add(userBulliten);
                    }
                    var evts = artist.SPRW_ARTIST_EVENT.OrderByDescending(i => i.EVENT_DATE).ToList();
                    foreach (var evt in evts)
                    {
                        var userEvent = new EventModel
                        {
                            Address     = evt.ADDRESS,
                            ArtistId    = artist.ARTIST_ID,
                            ArtistName  = artist.NAME,
                            Description = evt.DESCRP,
                            EventDate   = evt.EVENT_DATE,
                            City        = evt.CITY,
                            State       = evt.STATE,
                            Url         = evt.URL,
                            Name        = evt.NAME
                        };
                        userArtists.Events.Add(userEvent);
                    }
                }
                return(userArtists);
            }
        }
コード例 #2
0
 public HttpResponseMessage CreateArtistBulliten([FromBody] BullitenModel model)
 {
     if (_security.Verify(model.Token, model.UserEmail, model.ArtistId))
     {
         try
         {
             _artist.CreateBulliten(model);
             return(Request.CreateResponse(HttpStatusCode.Created));
         }
         catch (Exception e)
         {
             return(Request.CreateResponse(HttpStatusCode.BadRequest, e.StackTrace));
         }
     }
     return(Request.CreateResponse(HttpStatusCode.BadRequest));
 }
コード例 #3
0
        public int CreateBulliten(BullitenModel model)
        {
            try
            {
                using (var context = new sparrow_dbEntities())
                {
                    var bulliten = new ARTIST_BLOG
                    {
                        ACT_IND         = true,
                        BLOG            = model.Bulliten,
                        SPRW_ARTIST     = context.SPRW_ARTIST.FirstOrDefault(i => i.ARTIST_ID == model.ArtistId),
                        LAST_MAINT_TIME = DateTime.Now
                    };
                    context.ARTIST_BLOG.Add(bulliten);
                    context.SaveChanges();

                    return(bulliten.BLOG_ID);
                }
            }
            catch (Exception e)
            {
                throw e;
            }
        }
コード例 #4
0
 public int CreateBulliten(BullitenModel model)
 {
     return(Repository.CreateBulliten(model));
 }