public CheckIn Save(CheckIn entity) { try { switch (entity.ID) { case 0: entity.DataCriacao = DateTime.UtcNow; entity.DataEdicao = DateTime.UtcNow; entity.Ativo = true; var id = _repository.Add(entity); entity.ID = id; break; default: entity = Update(entity); break; } return(entity); } catch (Exception e) { throw new CheckInException("Não foi possível salvar o check-in informado.", e); } }
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); }