コード例 #1
0
ファイル: Provider.cs プロジェクト: hacktm15/hack
 public string CreateGroup(GroupViewModel viewModel)
 {
     var group = new Group
     {
         Description = viewModel.Description,
         FestivalId = viewModel.FestivalId,
         FestivalName = viewModel.FestivalName,
         GroupName = viewModel.GroupName,
         GroupSize = viewModel.GroupSize,
         LimitDate = viewModel.LimitDate,
         RoomBooked = !string.IsNullOrEmpty(viewModel.RoomId),
         RoomId = viewModel.RoomId,
         TransportBooked = viewModel.HasTransport
     };
     var groups = new List<Group> {@group};
     var admin = new Member
     {
         EmailAddress = viewModel.Email,
         Groups = groups
     };
     var party = new Party {GroupInfo = group, Leader = admin, Password = viewModel.Password};
     if (_context.Groups.Any(e=>e.GroupName.Equals(group.GroupName)))
     {
         return "A group with that name allready exists";
     }
     if (!_context.Members.Any(e => e.EmailAddress.Equals(admin.EmailAddress)))
     {
         _context.Members.Add(admin);
     }
     _context.Groups.Add(group);
     _context.Parties.Add(party);
     _context.SaveChanges();
     return null;
 }
コード例 #2
0
ファイル: Member.cs プロジェクト: hacktm15/hack
 protected bool Equals(Member other)
 {
     return string.Equals(EmailAddress, other.EmailAddress);
 }
コード例 #3
0
ファイル: Provider.cs プロジェクト: hacktm15/hack
 public string JoinParty(int partyId, string email)
 {
     var party = _context.Parties.FirstOrDefault(e => e.PartyId.Equals(partyId));
     if (party == null)
     {
         return "Party does not exist";
     }
     var member = _context.Members.FirstOrDefault(e => e.EmailAddress.Equals(email));
     if (member == null)
     {
         member = new Member {EmailAddress = email, Groups = new List<Group>()};
         _context.Members.Add(member);
     }
     if (party.PartyMembers.Count >= party.GroupInfo.GroupSize)
     {
         return "Party is full";
     }
     member.Groups.Add(party.GroupInfo);
     party.PartyMembers.Add(member);
     _context.SaveChanges();
     return null;
 }