Exemple #1
0
        public void AddEventArtist_ExistingTest()
        {
            Event myEvent = Event.NewEvent();

            myEvent.EventID = -1;

            Artist artist = Artist.NewArtist();

            artist.ArtistID = -1;

            Instrument instrument = Instrument.NewInstrument();

            instrument.InstrumentID = -1;

            EventArtist eventArtist = EventArtist.NewEventArtist();

            eventArtist.EventArtistID = -1;

            eventArtist.Artist     = artist;
            eventArtist.Event      = myEvent;
            eventArtist.Instrument = instrument;
            myEvent.EventArtists.Add(eventArtist);
            Assert.IsTrue(myEvent.EventArtists.Count == 1);


            myEvent.AddEventArtist(artist, instrument);
            Assert.IsTrue(myEvent.EventArtists.Count == 1);
        }
Exemple #2
0
 public int addEventArtist(EventArtist artist)
 {
     int result;
     try
     {
         this.db.EventArtists.InsertOnSubmit(artist);
         this.db.SubmitChanges();
         result = artist.EventArtistId;
     }
     catch (Exception)
     {
         result = -1;
     }
     return result;
 }
Exemple #3
0
 public bool removeEventArtist(EventArtist artist)
 {
     bool result;
     try
     {
         EventArtist entity = this.db.EventArtists.Single((EventArtist a) => a.EventArtistId == artist.EventArtistId);
         this.db.EventArtists.DeleteOnSubmit(entity);
         this.db.SubmitChanges();
         result = true;
     }
     catch (Exception)
     {
         result = false;
     }
     return result;
 }
Exemple #4
0
        public void AddEventArtistTest()
        {
            Event evt = Event.NewEvent();

            evt.EventID = -1;

            Artist artist = Artist.NewArtist();

            artist.ArtistID = -1;

            Instrument instrument = Instrument.NewInstrument();

            instrument.InstrumentID = -1;

            EventArtist eventArtist = EventArtist.AddEventArtist(evt, artist, instrument);

            Assert.IsNotNull(eventArtist);
            Assert.IsTrue(eventArtist.EventID == evt.EventID && eventArtist.ArtistID == artist.ArtistID);
        }
        public async Task <IActionResult> GetAllEvents()
        {
            ApplicationUser user = await _userManager.GetUserAsync(HttpContext.User);

            var roles = await _userManager.GetRolesAsync(user);

            List <EventArtist> eventArtists = new List <EventArtist>();

            eventArtists = await _context.EventArtist.Where(x => x.ArtistId == user.Id).ToListAsync();

            List <Event> events = new List <Event>();

            events = await _context.Event.ToListAsync();


            if (roles.Contains("Admin"))
            {
                return(Json(events));
            }
            else if (roles.Contains("Artist"))
            {
                List <Event> artistEvents = new List <Event>();

                foreach (Event @event in events)
                {
                    EventArtist eventArtist = await _context.EventArtist
                                              .Where(x => x.EventId == @event.Id && x.ArtistId == user.Id)
                                              .FirstOrDefaultAsync();

                    if (eventArtist != null)
                    {
                        artistEvents.Add(@event);
                    }
                }

                return(Json(artistEvents));
            }
            else
            {
                return(Json(events.Where(x => x.ClientId == user.Id)));
            }
        }
Exemple #6
0
        //// GET: Event
        //public ActionResult Index()
        //{
        //    EventRepository eventRepository = new EventRepository(new yslDataContext());
        //    var events = eventRepository.getArtistEvents(1);
        //    ViewBag.events = events;
        //    return View();
        //}
        //// GET: Event
        //public ActionResult View(int id)
        //{
        //    var eRepo = new EventRepository(new yslDataContext());
        //    var _event = eRepo.getEvent(id);
        //    var events = eRepo.getArtistEvents(1);
        //    events.Remove(_event);
        //    ViewBag._event = _event;
        //    ViewBag.events = events;
        //    return View();
        //}
        public ActionResult Processupload( string meta, string uploads, string people)
        {
            string[] source = uploads.Split(new char[]
            {
                '~'
            });
            PhotoRepository photoRepository = new PhotoRepository(new yslDataContext());
            EventArtistRepository eventArtistRepository = new EventArtistRepository(new yslDataContext());
            EventRepository eventRepository = new EventRepository(new yslDataContext());
            ArtistRepository artistRepository = new ArtistRepository(new yslDataContext());
            Request.Cookies.Get("ysl");
            var text = source.Last<string>().Split(',').ToList();
            string text2 = text.First();
            text2 = text2.Replace("/temp", "");
            var useDefaultImage = text2.Trim().ToLower().Equals("none");
            string text3 = "";
            string destFileName =  "";
            string photoName = "";
            if (!useDefaultImage)
            {
                text3 = Server.MapPath(text.First());
                destFileName = text3.Replace("\\temp", "");
                photoName = text.Last();
            }
            int accountId = int.Parse(System.Web.HttpContext.Current.User.Identity.GetUserId()) ;

            var metaFields = meta.Split('~').ToList();
            try
            {
                if (!useDefaultImage)
                {
                    System.IO.File.Move(text3, destFileName);
                }
                Photo photo = new Photo
                {
                    AccountId = accountId,
                    Title = photoName,
                    Description = "",
                    Location = text2,
                    Uploaded = DateTime.Now,
                    Updated = DateTime.Now
                };
                int value = (useDefaultImage) ? GlobalVariables.DefaultEventImageId : photoRepository.addPhoto(photo);
                var ys = artistRepository.getArtist(1);
                Event ev = new Event();
                ev.AccountId = accountId;
                ev.Title = metaFields[0];
                ev.Start = DateTime.Parse(metaFields[1] + " " + metaFields[2]);
                ev.Ending = DateTime.Parse(metaFields[3] + " " + metaFields[4]);

                ev.Location = metaFields[5];
                ev.Description = metaFields[6];
                ev.Venue = metaFields[7];

                ev.PhotoId = value;
                ev.Created = DateTime.Now;
                var evId = eventRepository.addEvent(ev);
                EventArtist eva = new EventArtist() { ArtistId = ys.ArtistId, EventId = evId };
                eventArtistRepository.addEventArtist(eva);

            }
            catch
            {
            }
            return View();
        }