public static void DataExchange(FsDataContext context) { List <Appointment> appointments = CreateAppointments(); List <Owner> owners = CreateOwner(); List <Announcement> announcements = CreateAnnouncements(); List <User> users = CreateUsers(); List <Place> places = CreatePlaces(); List <UserPlace> userPlaces = new List <UserPlace>(); List <UserPlace> userPlacesforUser = new List <UserPlace>(); foreach (var appointment in appointments) { var index = appointments.IndexOf(appointment); appointment.Place = index < 500 ? places[0] : places[1]; appointment.User = users[(index % 10)]; appointment.IsActive = false; } foreach (var owner in owners) { owner.Place = places[owners.IndexOf(owner)]; } foreach (var announcement in announcements) { var index = announcements.IndexOf(announcement); announcement.IsRead = false; announcement.Place = index < 10 ? places[0] : places[1]; } //for (int i = 0; i < users.Count; i++) //{ // var userPlace = new UserPlace(); // userPlace.Place = i < 50 ? places[0] : places[1]; // userPlace.PlaceId = i < 50 ? places[0].Id : places[1].Id; // userPlace.User = users[i]; // userPlace.UserId = users[i].Id; // userPlaces.Add(userPlace); //} foreach (var user in users) { UserPlace userPlace = new UserPlace(); var index = users.IndexOf(user); user.Place = new Place(); // user.UserPlaces.Add(userPlaces.FirstOrDefault(c => c.UserId == user.Id)); user.Appointments = appointments.GetRange(index * 10, 10); } foreach (var place in places) { var index = places.IndexOf(place); place.Owner = owners[places.IndexOf(place)]; place.Appointments = appointments.GetRange(index * 500, 500); place.Announcements = announcements.GetRange(index * 10, 10); place.Users = users.GetRange(index * 50, 50); } context.Appointments.AddRange(appointments); context.Owners.AddRange(owners); context.Announcements.AddRange(announcements); context.Users.AddRange(users); context.Places.AddRange(places); context.SaveChanges(); }
public BaseRepository() { Db = new FsDataContext(); RedisRepository = new RedisRepository(); }
public AuthRepository() { _db = new FsDataContext(); _userManager = GetUserManager(); }
public UserController(IUserService userService, UserRepository userRepository, FsDataContext fsDataContext) { _userService = userService; _userRepository = userRepository; _fsDataContext = fsDataContext; }
public DefaultController(FsDataContext context) { _context = context; }