示例#1
0
 public bool Add(Registration item)
 {
     try
     {
         item.User.Gender = _context.Gender.SingleOrDefault(s => s.Value == item.User.Gender.Value);
         _context.Registration.Add(item);
         _context.SaveChanges();
         return(true);
     }
     catch (Exception exception)
     {
         return(false);
     }
 }
示例#2
0
 public GenderRepository(EventRegistrationDbContext context)
 {
     _context = context;
     if ((this.GetAll()?.Count() <= 0))
     {
         _context.Gender.AddRange(new List <Gender>
         {
             new Gender
             {
                 Label = "Male",
                 Value = "M"
             },
             new Gender
             {
                 Label = "Female",
                 Value = "F"
             }
         });
         _context.SaveChanges();
     }
 }
 public DayRepository(EventRegistrationDbContext context)
 {
     _context = context;
     if ((this.GetAll()?.Count() <= 0))
     {
         _context.Day.AddRange(new List <Day>
         {
             new Day
             {
                 Label = "Day 1"
             },
             new Day
             {
                 Label = "Day 2"
             },
             new Day
             {
                 Label = "Day 3"
             }
         });
         _context.SaveChanges();
     }
 }