/// <summary> /// Implements <see cref="IStatisticsService.GetByUser(string, string, string, DateTime, DateTime)"/>. /// </summary> public IEnumerable <ActivityDTO> GetByUser(string name, string midname, string surname, DateTime start, DateTime end) { List <ActivityDTO> activities = new List <ActivityDTO>(); IdentityService identityService = new IdentityService(Database, SyncDatabase); CheckpointService checkpointService = new CheckpointService(Database); var identity = identityService.GetByName(name, midname, surname); if (identity != null) { foreach (var activity in Database.Activity.GetAll().Where(x => x.IdentityGUID == identity.GUID && x.Date > start && x.Date <= end)) { activities.Add(new ActivityDTO() { ID = activity.ID, User = identity, Checkpoint = checkpointService.GetByIP(activity.CheckpointIP), Mode = Database.Mode.GetAll().Where(x => x.ID == activity.ID).FirstOrDefault(), Date = activity.Date, Status = activity.Status }); } } return(activities); }
public ActivityDTO GetUserLocation(string guid) { IdentityService identityService = new IdentityService(Database, SyncDatabase); CheckpointService checkpointService = new CheckpointService(Database); var identity = identityService.GetByGUID(guid); if (identity != null) { var activity = Database.Activity.GetAll().Where(x => x.IdentityGUID == identity.GUID).LastOrDefault(); return(new ActivityDTO() { ID = activity.ID, User = identity, Checkpoint = checkpointService.GetByIP(activity.CheckpointIP), Mode = Database.Mode.GetAll().Where(x => x.ID == activity.ID).FirstOrDefault(), Date = activity.Date, Status = activity.Status }); } return(null); }
/// <summary> /// Implements <see cref="IStatisticsService.GetBySection(int, DateTime, DateTime)"/>. /// </summary> public IEnumerable <ActivityDTO> GetBySection(int section, DateTime start, DateTime end) { List <ActivityDTO> activities = new List <ActivityDTO>(); IdentityService identityService = new IdentityService(Database, SyncDatabase); CheckpointService checkpointService = new CheckpointService(Database); foreach (var checkpoint in Database.Checkpoint.GetAll().Where(y => y.Section == section)) { foreach (var activity in Database.Activity.GetAll().Where(x => x.CheckpointIP == checkpoint.IP && x.Date > start && x.Date <= end)) { activities.Add(new ActivityDTO() { ID = activity.ID, User = identityService.GetFull(activity.IdentityGUID), Checkpoint = checkpointService.GetByIP(activity.CheckpointIP), Mode = Database.Mode.GetAll().Where(x => x.ID == activity.ID).FirstOrDefault(), Date = activity.Date, Status = activity.Status }); } } return(activities); }