/// <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 name, string midname, string surname) { IdentityService identityService = new IdentityService(Database, SyncDatabase); CheckpointService checkpointService = new CheckpointService(Database); var identity = identityService.GetByName(name, midname, surname); 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); }