public async Task <IActionResult> Edit(int id, [Bind("Id,FirstName,LastName,Instrument,BandName")] BandMember bandMember)
        {
            if (id != bandMember.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(bandMember);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!BandMemberExists(bandMember.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(bandMember));
        }
Exemplo n.º 2
0
        public async Task <BandMember> AddMember(BandMember member)
        {
            var band = await dbContext
                       .Set <Entities.Band>()
                       .FindAsync(member.Band.Id);

            var bandit = await dbContext
                         .Set <Entities.Bandit>()
                         .FindAsync(member.Bandit.Id);

            var dbMember = new Entities.BandMember
            {
                Band    = band,
                Bandit  = bandit,
                Scoring = new Entities.Score()
            };

            await dbContext
            .Set <Entities.BandMember>()
            .AddAsync(dbMember);

            await dbContext.SaveChangesAsync();

            return(member);
        }
Exemplo n.º 3
0
        public void AddMembers(string first, string last, string term, string instrument)
        {
            var member = new BandMember()
            {
                Term = term
            };

            using (var context = new MusicContext())
            {
                member.Member = context.People.SingleOrDefault(b => b.FirstName.Equals(first) &&
                                                               b.LastName.Equals(last));
                member.Instrument = context.Instruments.SingleOrDefault(b => b.Description.Equals(instrument));
                member.Band       = context.Bands.SingleOrDefault(b => b.Name.Equals("Yes"));

                var existing = context.Bands.SingleOrDefault(b => b.Name.Equals("Yes") &&
                                                             b.Members.Count(m => m.Member.FirstName.Equals(first) &&
                                                                             m.Member.LastName.Equals(last) &&
                                                                             m.Instrument.Description.Equals(instrument)
                                                                             ) > 0
                                                             );

                if (existing == null)
                {
                    context.BandMembers.Add(member);
                    context.SaveChanges();
                }
            }
        }
Exemplo n.º 4
0
        public ActionResult Accept(int invitationId)
        {
            string userId = User.Identity.GetUserId();
            var    user   = db.Users
                            .Include(u => u.Bands)
                            .Where(u => u.Id == userId)
                            .FirstOrDefault();

            var invitation = db.Invitations.Find(invitationId);

            invitation.IsAccepted = true;
            db.SaveChanges();

            BandMember bandMember = new BandMember();

            bandMember.UserId = user.Id;
            bandMember.Title  = invitation.Title;
            bandMember.BandId = invitation.BandId;
            db.BandMembers.Add(bandMember);
            db.SaveChanges();

            var band = db.Bands
                       .Include(b => b.BandMembers)
                       .Where(b => b.BandId == invitation.BandId)
                       .FirstOrDefault();

            band.BandMembers.Add(bandMember);
            db.SaveChanges();

            return(RedirectToAction("Index", "BandMember", new { bandId = band.BandId }));
        }
Exemplo n.º 5
0
 public void ChangeSelection(BandMember member)
 {
     if (selected != member)
     {
         selected = member;
     }
 }
        public ActionResult DeleteConfirmed(long id)
        {
            BandMember bandMember = db.BandMembers.Find(id);

            db.BandMembers.Remove(bandMember);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit([Bind(Include = "Id,FirstName,LastName,Age,InstrumentPlayed")] BandMember bandMember)
 {
     if (ModelState.IsValid)
     {
         db.Entry(bandMember).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(bandMember));
 }
        public ActionResult Create([Bind(Include = "Id,FirstName,LastName,Age,InstrumentPlayed")] BandMember bandMember)
        {
            if (ModelState.IsValid)
            {
                db.BandMembers.Add(bandMember);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(bandMember));
        }
        public async Task <IActionResult> Create([Bind("Id,FirstName,LastName,Instrument,BandName")] BandMember bandMember)
        {
            if (ModelState.IsValid)
            {
                _context.Add(bandMember);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(bandMember));
        }
Exemplo n.º 10
0
        public async Task <Band> Get(int id)
        {
            var dbBand = await dbContext
                         .Set <Entities.Band>()
                         .Include(b => b.Boss)
                         .ThenInclude(b => b.Bandit)
                         .Include(b => b.Members)
                         .ThenInclude(bm => bm.Bandit)
                         .Include(b => b.Members)
                         .ThenInclude(bm => bm.Scoring)
                         .Include(b => b.Rounds)
                         .ThenInclude(r => r.Sheriff)
                         .ThenInclude(rm => rm.Member)
                         .ThenInclude(bm => bm.Bandit)
                         .FirstOrDefaultAsync(b => b.Id == id);

            if (dbBand == null)
            {
                return(null);
            }

            var boss = Bandit.Create(dbBand.Boss.Bandit.Id, dbBand.Boss.Bandit.Name, dbBand.Boss.Bandit.Email);
            var band = Band.Create(dbBand.Id, dbBand.Name, boss);

            foreach (var dbMember in dbBand.Members)
            {
                if (dbMember.Bandit.Id == band.Boss.Bandit.Id)
                {
                    band.Members.Add(band.Boss);
                    continue;
                }

                var bandit = Bandit.Create(dbMember.Bandit.Id, dbMember.Bandit.Name, dbMember.Bandit.Email);
                var member = BandMember.From(bandit, band);

                var score = dbMember.Scoring.ToModel();
                member.Scoring.Add(score);

                band.Members.Add(member);
            }

            foreach (var dbRound in dbBand.Rounds)
            {
                var dbBandit = dbRound.Sheriff.Member.Bandit;
                var bandit   = Bandit.Create(dbBandit.Id, dbBandit.Name, dbBandit.Email);

                var sheriff = BandMember.From(bandit, band);
                var round   = Round.Create(dbRound.Id, dbRound.Name, dbRound.Place, dbRound.DateTime, sheriff, Enumerable.Empty <BandMember>());

                band.Rounds.Add(round);
            }

            return(band);
        }
Exemplo n.º 11
0
 void SwitchToCharacter(int CHAR)
 {
     currentCharacter = CHAR;
     if (character)
     {
         character.controlled = false;
     }
     character                       = playableCharacters[CHAR];
     character.controlled            = true;
     currentCharacterPortrait.sprite = character.portrait;
     character.selectionCircle.SetActive(true);
 }
        // GET: BandMembers/Delete/5
        public ActionResult Delete(long?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            BandMember bandMember = db.BandMembers.Find(id);

            if (bandMember == null)
            {
                return(HttpNotFound());
            }
            return(View(bandMember));
        }
Exemplo n.º 13
0
        //[ValidateAntiForgeryToken]
        public async Task <IActionResult> Create([Bind("Id,FirstName,LastName,Instrument,BandName")] BandMember bandMember)
        {
            if (ModelState.IsValid)
            {
                var bandObject = _context.Bands.Where(band => band.BandName == bandMember.BandName).FirstOrDefault();
                bandMember.Band    = new Band();
                bandMember.Band.Id = bandObject.Id;
                _context.Add(bandMember);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(bandMember));
        }
Exemplo n.º 14
0
        public ActionResult RemoveMember(int?bandId, int bandMemberId)
        {
            var band = db.Bands
                       .Include(b => b.BandMembers)
                       .Where(b => b.BandId == bandId)
                       .FirstOrDefault();

            BandMember bandMember = band.BandMembers.Where(m => m.BandMemberId == bandMemberId).FirstOrDefault();

            band.BandMembers.Remove(bandMember);
            db.SaveChanges();
            TempData["infoMessage"] = bandMember.Title + " removed from your band.";
            return(RedirectToAction("Members", "Band", new { bandId = bandId }));
        }
Exemplo n.º 15
0
        public async Task <DTOs.Notification> Invite(DTOs.InviteJoinBand request)
        {
            var host = await banditRepository.Get(request.Host.Id);

            if (host == null)
            {
                throw new NotFoundException("Bandit", request.Host.Id);
            }

            var guest = await banditRepository.Get(request.Guest.Id);

            if (guest == null)
            {
                throw new NotFoundException("Bandit", request.Guest.Id);
            }

            var band = await bandRepository.Get(request.Band.Id);

            if (band == null)
            {
                throw new NotFoundException("Band", request.Band.Id);
            }

            if (!band.IsMember(host))
            {
                throw new InvalidOperationException(Strings.CantInviteToJoin.Format(host.Name, guest.Name, band.Name));
            }

            var member = BandMember.From(host, band);

            if (!member.CanInviteToJoin(guest))
            {
                throw new InvalidOperationException(Strings.CantInviteToJoin.Format(host.Name, guest.Name, band.Name));
            }

            var invitation = Invitation.Create(guest, band, guest);
            await invitationRepository.Add(invitation);

            var message = Notifications.InviteJoinBand(host.Name, band.Name);
            await notifications.Send(message, to : guest);

            return(new DTOs.Notification
            {
                To = guest.Name,
                Title = message.Title,
                Content = message.Body
            });
        }
Exemplo n.º 16
0
        public async Task <DTOs.Invitation> Handle(DTOs.HandleInvitation request)
        {
            var invitation = await invitationRepository.Get(request.Invitation.Id);

            if (invitation == null)
            {
                throw new NotFoundException("Invitation", request.Invitation.Id);
            }

            await invitationRepository.Remove(invitation.Id);

            if (!request.Accept)
            {
                return(invitation.ToDto());
            }

            var bandMember = BandMember.From(invitation.Guest, invitation.Band);
            await bandRepository.AddMember(bandMember);

            return(invitation.ToDto());
        }
Exemplo n.º 17
0
        public async Task <Bandit> FindByEmail(string email)
        {
            var dbBandit = await dbContext
                           .Set <Entities.Bandit>()
                           .Include(b => b.Scoring)
                           .Include(b => b.Bands)
                           .ThenInclude(bm => bm.Band)
                           .ThenInclude(b => b.Boss)
                           .ThenInclude(bm => bm.Bandit)
                           .Include(b => b.Bands)
                           .ThenInclude(bm => bm.Scoring)
                           .FirstOrDefaultAsync(b => b.Email == email);

            if (dbBandit == null)
            {
                return(null);
            }

            var bandit = Bandit.Create(dbBandit.Id, dbBandit.Name, dbBandit.Email);
            var score  = dbBandit.Scoring.ToModel();

            bandit.Scoring.Add(score);

            foreach (var dbBand in dbBandit.Bands)
            {
                var dbBoss = dbBand.Band.Boss.Bandit;
                var boss   = Bandit.Create(dbBoss.Id, dbBoss.Name, dbBoss.Email);

                var band = Band.Create(dbBand.Band.Id, dbBand.Band.Name, boss);

                var scoring = dbBand.Scoring.ToModel();

                var bandMember = BandMember.From(bandit, band);
                bandMember.Scoring.Add(scoring);

                bandit.Bands.Add(bandMember);
            }

            return(bandit);
        }
Exemplo n.º 18
0
        public async Task <IQueryable <Band> > Get()
        {
            var dbBands = dbContext
                          .Set <Entities.Band>()
                          .Include(b => b.Boss)
                          .ThenInclude(bm => bm.Bandit)
                          .Include(b => b.Rounds)
                          .ThenInclude(r => r.Sheriff)
                          .ThenInclude(rm => rm.Member)
                          .ThenInclude(bm => bm.Bandit);

            await dbBands.LoadAsync();

            var bands = dbBands
                        .AsEnumerable()
                        .Select(b => {
                var boss = Bandit.Create(b.Boss.Bandit.Id, b.Boss.Bandit.Name, b.Boss.Bandit.Email);
                var band = Band.Create(b.Id, b.Name, boss);

                foreach (var dbRound in b.Rounds)
                {
                    var dbBandit = dbRound.Sheriff.Member.Bandit;
                    var bandit   = Bandit.Create(dbBandit.Id, dbBandit.Name, dbBandit.Email);

                    var sheriff = BandMember.From(bandit, band);
                    var round   = Round.Create(dbRound.Id, dbRound.Name, dbRound.Place, dbRound.DateTime, sheriff, Enumerable.Empty <BandMember>());

                    band.Rounds.Add(round);
                }

                return(band);
            })
                        .AsQueryable();

            return(bands);
        }
Exemplo n.º 19
0
 // Start is called before the first frame update
 void Start()
 {
     c     = GetComponentInParent <BandMember>();
     layer = c.layer;
     anim  = GetComponent <Animator>();
 }
Exemplo n.º 20
0
 public void CancelSelection()
 {
     selected = null;
 }