public void CheckInTable_NotNull_WhenCheckInTableIsCalledWithValidCredentials() { var checkIn = new CheckInRepository(new AzureStorageCredentials()) .CheckInTable(); Assert.IsNotNull(checkIn); }
public async Task <IActionResult> CheckInVolunteer(IdModel model) { var user = await userManager.GetUserAsync(User); if (user == null || !(await userManager.IsInRoleAsync(user, UserHelpers.UserRoles.Staff.ToString()))) { return(Utilities.ErrorJson("Not authorized.")); } if (model == null || model.Id == 0) { return(Utilities.GenerateMissingInputMessage("volunteer id")); } try { CheckInRepository repo = new CheckInRepository(configModel.ConnectionString); return(new JsonResult(new { NumVisits = repo.CheckInVolunteer(model.Id) })); } catch (Exception exc) { return(new JsonResult(new { Error = exc.Message, })); } }
public async Task <IActionResult> CheckInBusDriver(DriverCheckInModel model) { var user = await userManager.GetUserAsync(User); CheckInRepository repo = new CheckInRepository(configModel.ConnectionString); VolunteerRepository volRepo = new VolunteerRepository(configModel.ConnectionString); VolunteerModel profile; if (user == null || !(await userManager.IsInRoleAsync(user, UserHelpers.UserRoles.Staff.ToString()))) { return(Utilities.ErrorJson("Not authorized.")); } if (model == null || model.Id == 0) { return(Utilities.GenerateMissingInputMessage("bus driver id")); } if (model.Date == DateTime.MinValue) { return(Utilities.GenerateMissingInputMessage("date")); } if (model.Date.DayOfWeek != DayOfWeek.Saturday) { return(Utilities.ErrorJson("Drivers can only be checked in for Saturdays")); } if (DateTime.Today.Date.AddDays(7) < model.Date) { return(Utilities.ErrorJson("Date is too far in the future. Bus drivers can only be checked in for the next Saturday")); } try { profile = volRepo.GetVolunteer(model.Id); if (profile == null || profile.Role != UserHelpers.UserRoles.BusDriver.ToString()) { return(Utilities.ErrorJson("Not a valid bus driver")); } repo.CheckInBusDriver(model.Id, model.Date); } catch (Exception e) { return(Utilities.ErrorJson(e.Message)); } return(Utilities.NoErrorJson()); }
/// <summary> /// Here we do all the business /// </summary> /// <param name="obj"></param> public void DeleteCfProfileAndRelatedData(Profile u) { //-- Delete any personality media var pMediaRepo = new UserPersonalityMediaRepository(); var mediaRepo = new MediaRepository(); var mediaOpinionRepo = new MediaOpinionRepository(); var opinionRepo = new OpinionRepository(); var ciRepo = new CheckInRepository(); var pcRepo = new PartnerCallRepository(); var postRepo = new PostRepository(); var clmRepo = new ClimbRepository(); mediaOpinionRepo.Delete(mediaOpinionRepo.GetAll().Where(mo => mo.UserID == u.ID).Select(mo => mo.ID)); opinionRepo.Delete(opinionRepo.GetAll().Where(o => o.UserID == u.ID).Select(o => o.ID)); postRepo.Delete(postRepo.GetAll().Where(p => p.UserID == u.ID).Select(p => p.ID)); //-- Delete personality media mediaRepo.Delete(pMediaRepo.GetAll().Where(pm => pm.UserID == u.ID).Select(pm => pm.MediaID)); //-- Get other media, e.g. stuff uploaded for places & climbs //-- Remove all the personal tags mediaRepo.RemoveAllMediaTagForObject(u.ID); var otherMedia = mediaRepo.GetAll().Where(pm => pm.AddedByUserID == u.ID); foreach (var m in otherMedia) { m.AddedByUserID = Stgs.SystemID; } mediaRepo.Update(otherMedia); ciRepo.Delete(ciRepo.GetAll().Where(ci => ci.UserID == u.ID).Select(ci => ci.ID)); pcRepo.Delete(pcRepo.GetAll().Where(pc => pc.UserID == u.ID).Select(pc => pc.ID)); //-- geo problems , e.g. a user ads a area, location or climb or is listed as a setter var usersSetClimbs = clmRepo.GetAll().Where(c => c.SetterID == u.ID); foreach (var c in usersSetClimbs) { c.SetterID = null; } clmRepo.Update(usersSetClimbs); //-- If everything else has been removed this should work.... profileRepo.Delete(u.ID); }
public void CheckIn_True_CorrectInputs_WithAzureRepositoryK() { var checkInRepository = new CheckInRepository(new AzureStorageCredentials()); var RegistrationServicesMOCK = new Mock <IRSAssistantRole>(); RegistrationServicesMOCK.Setup(marge => marge.GetUsersBySession(It.IsAny <int>())) .Returns(new List <UserTO> { new UserTO { Id = 1 } , new UserTO { Id = 2 } , new UserTO { Id = 3 } , new UserTO { Id = 4 } }); RegistrationServicesMOCK.Setup(marge => marge.GetSessionById(It.IsAny <int>())) .Returns(new SessionTO { Id = 999999999, SessionDays = new List <SessionDayTO> { new SessionDayTO { Id = 1, Date = DateTime.Now, PresenceType = SessionPresenceType.OnceADay } } }); var checkInArgs = new CheckInTO { SessionId = 999999999, AttendeeId = 3, CheckInTime = DateTime.Now }; var eleve = new ASAttendeeRole(checkInRepository, RegistrationServicesMOCK.Object); var valueToAssert = eleve.CheckIn(checkInArgs); Assert.IsTrue(valueToAssert); }
public void CheckInTable_ReturnTableInstance_WhenAddIsCalledWithValidCheckIn() { var checkInArgs = new CheckInTO { SessionId = 999999999, AttendeeId = 333333333, CheckInTime = DateTime.Now }; ICheckInRepository repo = new CheckInRepository(new AzureStorageCredentials()); var addCheckIn = repo.Add(checkInArgs); Assert.IsNotNull(addCheckIn); Assert.AreNotEqual(Guid.Empty, addCheckIn.Id); Assert.AreEqual(checkInArgs.AttendeeId, addCheckIn.AttendeeId); Assert.IsTrue(addCheckIn.CheckInTime.IsSameDate(checkInArgs.CheckInTime)); Assert.AreEqual(checkInArgs.SessionId, addCheckIn.SessionId); }
public void GetAttendeeCheckIns_ReturnCheckInList_WhenAValidAttendeeIdIsProvided() { var checkInArgs = new CheckInTO { SessionId = 999999999, AttendeeId = 333333333, CheckInTime = DateTime.Now }; ICheckInRepository repo = new CheckInRepository(new AzureStorageCredentials()); //Inserting at list one... for test sake var addCheckIn = repo.Add(checkInArgs); var checkInList = repo.GetAttendeeCheckIns(checkInArgs.AttendeeId); Assert.IsNotNull(checkInList); Assert.IsTrue(checkInList.Count >= 1); }
private bool HasCheckedInToday(string username) { var lastCheckin = CheckInRepository.GetLastCheckIn(username); return(lastCheckin.Date == DateTime.Today.Date); }
public CheckInDomain(CheckInRepository repository) { _repository = repository; }
public async Task <IActionResult> CancelBusDriver(DriverCheckInModel model) { var user = await userManager.GetUserAsync(User); CheckInRepository repo = new CheckInRepository(configModel.ConnectionString); CalendarRepository calRepo = new CalendarRepository(configModel.ConnectionString); AttendanceModel attendance; VolunteerRepository volRepo = new VolunteerRepository(configModel.ConnectionString); VolunteerModel profile; if (user == null || !(await userManager.IsInRoleAsync(user, UserHelpers.UserRoles.Staff.ToString()))) { return(Utilities.ErrorJson("Not authorized.")); } if (model == null || model.Id == 0) { return(Utilities.GenerateMissingInputMessage("bus driver id")); } if (model.Date == DateTime.MinValue) { return(Utilities.GenerateMissingInputMessage("date")); } if (model.Date.DayOfWeek != DayOfWeek.Saturday) { return(Utilities.ErrorJson("Drivers can only be checked in for Saturdays")); } if (DateTime.Today.Date > model.Date) { return(Utilities.ErrorJson("Can not cancel check in in the past")); } try { profile = volRepo.GetVolunteer(model.Id); if (profile == null || profile.Role != UserHelpers.UserRoles.BusDriver.ToString()) { return(Utilities.ErrorJson("Not a valid bus driver")); } attendance = calRepo.GetSingleAttendance(model.Id, model.Date); if (attendance == null || !attendance.Attended) { return(Utilities.ErrorJson("Not currently checked in")); } repo.CancelBusDriver(model.Id, model.Date); } catch (Exception e) { return(Utilities.ErrorJson(e.Message)); } return(Utilities.NoErrorJson()); }