public void AddLocation(LocationDao location) { var latId = (int)((location.Latitude - _latitudeDownBoundary) / _latStep); var longId = (int)((location.Longitude - _longitudeDownBoundary) / _longStep); var timeId = (int)((location.Time - _timeDownBoundary) / _timeStep); var cube = _coronaContext.Cubes.FirstOrDefault(c => c.LatId == latId && longId == c.LongId && timeId == c.TimeId); if (cube == null) { cube = new Cube { LatId = latId, LongId = longId, TimeId = timeId }; _coronaContext.Cubes.Add(cube); } var dbLocation = new Location { AddDate = DateTime.Now, Latitude = location.Latitude, Longitude = location.Longitude, LatId = cube.LatId, LongId = cube.LongId, TimeId = cube.TimeId, Time = location.Time, UserId = location.UserId }; _coronaContext.Locations.Add(dbLocation); _coronaContext.SaveChanges(); }
public void AddAdmin(string login, string password, string deviceId) { _coronaContext.Auths.Add(new Auth { Login = login, Password = password }); _userRepository.AddUser(deviceId, "", true); _coronaContext.SaveChanges(); }
public void AddUser(string deviceId, string notificationId, bool isAdmin) { var user = new User { AddDate = DateTime.Now, DeviceId = deviceId, NotificationId = notificationId, UserType = isAdmin ? UserType.Doctor : UserType.Normal }; _coronaContext.Users.Add(user); _coronaContext.SaveChanges(); }
public static void SaveVirusInfo(string virusInfo) { CoronaContext coronaContext = new CoronaContext(); coronaContext.Database.EnsureCreated(); CoronaVirusSummary coronaVirusSummary = coronaContext.CoronaVirusSummaries.SingleOrDefault(x => x.Date == DateTime.Today); if (coronaVirusSummary == null) { coronaContext.CoronaVirusSummaries.Add(new CoronaVirusSummary() { Date = DateTime.Today, VirusInfo = virusInfo }); coronaContext.SaveChanges(); } else { coronaVirusSummary.VirusInfo = virusInfo; coronaContext.SaveChanges(); } }