コード例 #1
0
        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();
        }
コード例 #2
0
 public BaseRepository()
 {
     Db = new FsDataContext();
     RedisRepository = new RedisRepository();
 }
コード例 #3
0
 public AuthRepository()
 {
     _db          = new FsDataContext();
     _userManager = GetUserManager();
 }
コード例 #4
0
 public UserController(IUserService userService, UserRepository userRepository, FsDataContext fsDataContext)
 {
     _userService    = userService;
     _userRepository = userRepository;
     _fsDataContext  = fsDataContext;
 }
コード例 #5
0
 public AuthRepository()
 {
     _db = new FsDataContext();
     _userManager = GetUserManager();
 }
コード例 #6
0
 public DefaultController(FsDataContext context)
 {
     _context = context;
 }
コード例 #7
0
 public BaseRepository()
 {
     Db = new FsDataContext();
     RedisRepository = new RedisRepository();
 }