public HttpResponseMessage UpdateVisitor(VisitorUpdateRequest model) { if (!ModelState.IsValid) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState)); } _openHouseService.UpdateVisitor(model); SuccessResponse response = new SuccessResponse(); return(Request.CreateResponse(HttpStatusCode.OK, response)); }
public async Task ItShouldThrowAnExceptionIfVisitorNotFound() { var @event = new VisitorUpdateRequest() { Email = "*****@*****.**", }; var exception = await Assert.ThrowsAsync <Exception>(async() => { var result = await _checkInHandler.HandleCheckIn(@event); }).ConfigureAwait(false); }
public async Task FindVisitorAndGenerateCredentials() { var @event = new VisitorUpdateRequest() { Email = "*****@*****.**" }; var result = await _checkInHandler.HandleCheckIn(@event); Assert.Equal("dtargaryen", result.Username); Assert.Equal("308f0103", result.Password); }
public void UpdateVisitor(VisitorUpdateRequest model) { DataProvider.ExecuteNonQuery(GetConnection, "dbo.OpenHouseVisitors_Update" , inputParamMapper : delegate(SqlParameterCollection paramCollection) { paramCollection.AddWithValue("@id", model.Id); paramCollection.AddWithValue("@firstName", model.FirstName); paramCollection.AddWithValue("@lastName", model.LastName); paramCollection.AddWithValue("@email", model.Email); paramCollection.AddWithValue("@phoneNumber", model.PhoneNumber); paramCollection.AddWithValue("@lookingForAgent", model.LookingForAgent); paramCollection.AddWithValue("@wantsUpdates", model.WantsUpdates); paramCollection.AddWithValue("@sendSimilar", model.SendSimilar); }, returnParameters: null); }
public async Task CanFindVisitorAndResolveMismatch() { var @event = new VisitorUpdateRequest() { Email = "*****@*****.**", FirstName = "Khal", LastName = "Drogo" }; var result = await _checkInHandler.HandleCheckIn(@event); Assert.Equal("kdrogo", result.Username); Assert.Equal("81f9d5db", result.Password); _visitorService.Verify(x => x.UpdateVisitor(It.Is <VisitorUpdateRequest>(s => s.FirstName == "Khal" && s.LastName == "Drogo")), Times.Once); }
public async Task ItShouldStoreCredentialsAndNotStoreItTwice() { var @event = new VisitorUpdateRequest() { Email = "*****@*****.**", }; var result = await _checkInHandler.HandleCheckIn(@event); Assert.Equal("jsnow", result.Username); Assert.Equal("48c2cf16", result.Password); result = await _checkInHandler.HandleCheckIn(@event); Assert.Equal("jsnow", result.Username); Assert.Equal("48c2cf16", result.Password); _credentialService.Verify(x => x.Generate(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>()), Times.Once); }
public Task <CredentialEntity> HandleCheckIn(VisitorUpdateRequest visitorEvent) { //Make sure to strongly type the return object here throw new System.NotImplementedException(); }