Exemple #1
0
 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;
 }
Exemple #2
0
 protected bool Equals(Group other)
 {
     return string.Equals(GroupName, other.GroupName);
 }
Exemple #3
0
 private static bool ComapreGroups(GroupViewModel viewModel, Group existingGroup)
 {
     return existingGroup.GroupName.Equals(viewModel.GroupName) && !existingGroup.GroupId.Equals(viewModel.GroupId) &&
            existingGroup.FestivalName.Equals(viewModel.FestivalName);
 }