/// <summary> /// Modify Room /// </summary> /// <param name="room">Room</param> public void Modify(Model.Room.Room room) { if (room == null || room.IsValid() == false) { throw new ValidationException(ErrorFactory.CreateAndLogError(Errors.SRVEX30068, "RoomManager.Modify", arguments: new object[] { this })); } Model.Room.Room existingRoom = roomDao.GetByName(room.Name, room.BusinessId); if (existingRoom != null && existingRoom.Id != room.Id) { throw new ValidationException(ErrorFactory.CreateAndLogError(Errors.SRVEX30085, "RoomManager.Modify", additionalDescriptionParameters: (new object[] { room.BusinessId }))); } var bookings = bookingManager.GetByRoom(room.Id).AsQueryable().Where(b => b.StartDate >= DateTime.UtcNow || b.EndDate >= DateTime.UtcNow); // If any were found throw validation exception if trying to change status if (bookings.Any() && room.RoomStatusCode != RoomStatusCodes.ACTIVE) { throw new ValidationException(ErrorFactory.CreateAndLogError(Errors.SRVEX30097, "RoomManager.Modify", arguments: new object[] { this })); } using (var businessTransaction = new BusinessTransaction()) { roomDao.Modify(room); businessTransaction.Commit(); } eventTrackingManager.CreateBusinessEventAsync(room.BusinessId, BusinessEventTypesEnum.RoomModified, room.Id.ToString(CultureInfo.InvariantCulture)); }
public void RequiredIfTrue_ConditionMetWithTrueAndValueSupplied_RequiredAndValidates() { var model = new Model() { Value1 = true, Value2 = "supplied" }; Assert.IsTrue(model.IsValid("Value2")); }
public void IsNotRequiredToHaveMaxElementsWithValue1NullTest() { var model = new Model() { Value1 = null }; Assert.IsTrue(model.IsValid("Value2")); }
public void IsNotRequiredWithValue1NullTest() { var model = new Model() { Value1 = null, Value2 = null }; Assert.IsTrue(model.IsValid("Value2")); }
public void IsNotValidTest() { var model = new Model() { Value1 = true, Value2 = "not a time" }; Assert.IsFalse(model.IsValid("Value2")); }
public void IsNotValidWithValue2NullTest() { var model = new Model() { Value1 = "hello", Value2 = null }; Assert.IsFalse(model.IsValid("Value2")); }
public void IsValidTestIfValue2IsNull() { var model = new Model() { Value1 = AnEnum.C, Value2 = null }; Assert.IsTrue(model.IsValid("Value2")); }
public void RequiredIfRegExMatch_ConditionMetWithMatchingValueAndNoValueSupplied_RequiredAndFails() { var model = new Model() { Value1 = "8:30 AM" }; Assert.IsFalse(model.IsValid("Value2")); }
public void IsValidTest() { var model = new Model() { Value1 = AnEnum.C, Value2 = new string[] { "hello", "hello2", "hello3" } }; Assert.IsTrue(model.IsValid("Value2")); }
public void IsValid2Test() { var model = new Model() { Value1 = AnEnum.B, Value2 = null }; Assert.IsTrue(model.IsValid("Value2")); }
public void IsValidWithValue2NullTest() { var model = new Model() { Value1 = "goodbye", Value2 = null }; Assert.IsTrue(model.IsValid("Value2")); }
public void IsValidTest() { var model = new Model() { Value1 = AnEnum.A, Value2 = "hello" }; Assert.IsTrue(model.IsValid("Value2")); }
public void RequiredIfRegExMatch_ConditionMetWithNonMatchingValue_NotRequiredAndValidates() { var model = new Model() { Value1 = "hello" }; Assert.IsTrue(model.IsValid("Value2")); }
public void RequiredIfTrue_ConditionMetWithTrueAndNoValueSupplied_RequiredAndFails() { var model = new Model() { Value1 = true, Value2 = string.Empty }; Assert.IsFalse(model.IsValid("Value2")); }
public void IsNotValidTest() { var model = new Model() { Value1 = "hello", Value2 = new string[] { "hello", "hello2" } }; Assert.IsFalse(model.IsValid("Value2")); }
public void RequiredIfTrue_ConditionMetWithFalse_NotRequiredAndValidates() { var model = new Model() { Value1 = false }; Assert.IsTrue(model.IsValid("Value2")); }
public void IsValid() { var model = new Model() { Value1 = "hello", Value2 = "hello" }; Assert.IsTrue(model.IsValid("Value2")); }
public void IsValidTest() { var model = new Model() { Value1 = true, Value2 = "8:30 AM" }; Assert.IsTrue(model.IsValid("Value2")); }
public void IsNotValidWithValue1Null() { var model = new Model() { Value2 = "hello" }; Assert.IsFalse(model.IsValid("Value2")); }
public void IsNotValidTest() { var model = new Model() { Value1 = "hello", Value2 = "" }; Assert.IsFalse(model.IsValid("Value2")); }
public void IsNotRequiredTest() { var model = new Model() { Value1 = "", Value2 = "" }; Assert.IsTrue(model.IsValid("Value2")); }
public void IsNotRequiredToHaveMaxElementsTest() { var model = new Model() { Value1 = "goodbye" }; Assert.IsTrue(model.IsValid("Value2")); }
public void RequiredIfTrue_ConditionMetWithNull_NotRequiredAndValidates() { var model = new Model() { Value3 = null }; Assert.IsTrue(model.IsValid("Value4")); }
public void RequiredIfRegExMatch_ConditionMetWithMatchingValueAndValueSupplied_RequiredAndValidates() { var model = new Model() { Value1 = "8:30 AM", Value2 = "supplied" }; Assert.IsTrue(model.IsValid("Value2")); }
public void GetTest() { Model target = _ModelClient.Get(_TargetModelId); Assert.IsTrue(target.IsValid()); Assert.AreEqual("wheel.stl", target.Name); Assert.AreEqual(2153357, target.Size); Assert.AreEqual(Ftype.File, target.Ftype); Assert.AreEqual(false, target.Readonly); }
private async void ConfirmationCommandHandler() { if (Model.IsValid()) { await _popupNavigation.PushAsync(new LoadingPopupPage()); var packingListViewInfo = await _boardingDeliveryPackService.ReadingPackDelivery( new ReadingPackDeliveryModel(Model.PackingListViewInfo.Id, Model.PackingListViewInfo.TrafficScheduleDetailId, _userService.User.Unit.Id, Model.Reading, _wifiService.MacAddress, false)); await _popupNavigation.PopAllAsync(); if (packingListViewInfo.Response != null && packingListViewInfo.Response.Valid) { Model.VehicleViewInfo.OperationalControlId = packingListViewInfo.Response.OperationalControlId; SetPackingListDelivery(packingListViewInfo.Response); } else if (packingListViewInfo.Response != null) { switch (packingListViewInfo.Response.ExceptionCode) { case ExceptionCodeEnum.PackRead: if (await _notificationService.AskQuestionAsync( $"{packingListViewInfo.Response.ExceptionMessage}\r\nDeseja estornar o volume registrado na leitura atual?", SoundEnum.Alert)) { CallConfirmationRandomPopupPage(CancelPackBoarding, new CancelPackBoardingModel(Model.PackingListViewInfo.Id, Model.Reading, _wifiService.MacAddress, false, true)); } else if (await _notificationService.AskQuestionAsync( $"{packingListViewInfo.Response.ExceptionMessage}\r\nVeículo{ Model.VehicleViewInfo.CarNumber}" + $"\r\nDeseja estornar todo o CTRC do volume registrado na leitura atual?", SoundEnum.Alert)) { CallConfirmationRandomPopupPage(CancelBillOfLadingBoarding, new CancelBillOfLadingBoardingModel(Model.PackingListViewInfo.Id, Model.Reading, _wifiService.MacAddress, false)); } break; //case ExceptionCodeEnum.PackNotFoundWarehouse: // if (await ShowQuestionDialogSpeech(packingListViewInfo.Response.ExceptionMessage)) // return ReadingPackDeliveryBoarding(trafficScheduleDetailId, packingListId, unitLocal, textBoxBarCode, vehicle, packAmount, packAmountReading, true); // break; default: await _notificationService.NotifyAsync(packingListViewInfo.Response.ExceptionMessage, SoundEnum.Erros); break; } } } }
public void AddCustomPropertyExpressionTest() { var model = new Model { Password = "******" }; var validationResults = new List <ValidationResult>(); Assert.IsFalse(model.IsValid(validationResults)); Assert.AreEqual(CustomMessage, validationResults.Single().ErrorMessage); }
private void btnCreateFolder_Click(object sender, EventArgs e) { frmCreateFolder target = new frmCreateFolder(ModelClient); if (target.ShowDialog(this) == DialogResult.OK) { Model folder = ModelClient.Create(target.ModelName, target.ModelId); if (Model.IsValid(folder)) { } } }
public void UpdateTest() { Model origin = _Model; _Model.Description = "changed"; _Model.Name = "wheel2.stl"; Model updated = _Model.Update(); Assert.IsTrue(updated.IsValid()); Assert.AreEqual(_Model.Description, updated.Description); Assert.AreEqual(_Model.Name, updated.Name); origin.Update(); }
private async void ConfirmationCommandHandler() { if (Model.IsValid()) { ReadingPackAccessory(new ReadingPackAccessoryModel(false, Model.PackingListViewInfo.Id, _userService.User.Unit.Id, Model.UnitViewInfo.Id, Model.Reading, _wifiService.MacAddress)); Model.Reading = String.Empty; Model.ReadingFocus(); } else { await _notificationService.NotifyAsync("Informe todos os campos obrigatórios.", SoundEnum.Alert); } }
/// <summary> /// Create User /// </summary> /// <remarks> /// The user to create will have a default password associated in the initial stage. /// Things like password and security question and security password should be created at /// a later stage during the activation process /// </remarks> /// <param name="user">User to create</param> /// <returns>Guid of the created user</returns> public Guid Create(Model.User.User user) { var newUserId = Guid.Empty; if (!user.IsValid()) { throw new ValidationException(ErrorFactory.CreateAndLogError(Errors.SRVEX30052, "UserManager.create")); } MembershipCreateStatus createStatus; MembershipUser newUser = Membership.CreateUser(user.UserName, DefaultPassword, user.UserName, DefaultPasswordQuestion, DefaultPasswordAnswer, true, out createStatus); if (createStatus != MembershipCreateStatus.Success) { throw new ValidationException(ErrorFactory.CreateAndLogError(Errors.SRVEX30053, "Membership.CreateUser")); } if (newUser != null && newUser.ProviderUserKey != null) { var newUserIdentifier = (Guid)newUser.ProviderUserKey; userExtensionDao.Create(new UserExtension { UserId = newUserIdentifier, FirstName = user.Extension.FirstName, LastName = user.Extension.LastName, CultureCode = user.Extension.CultureCode }); RecordUserEvent(user.UserName, UserEventTypesEnum.UserCreated); newUserId = newUserIdentifier; } return newUserId; }
/// <summary> /// Modify User /// </summary> /// <param name="user">User</param> public void Modify(Model.User.User user) { if (!user.IsValid()) { throw new ValidationException(ErrorFactory.CreateAndLogError(Errors.SRVEX30051, "UserManager.Modify")); } using (var btx = new BusinessTransaction()) { userDao.Modify(user); // Update UserExtension userExtensionDao.Modify(user.Extension); //make sure to update the membership with the new user name used var membershipUser = Membership.GetUser(user.Id); if (membershipUser != null) { membershipUser.Email = user.UserName; Membership.UpdateUser(membershipUser); } RecordUserEvent(user.UserName, UserEventTypesEnum.UserModified); btx.Commit(); } }
public void IsNotValidWithNulls() { var model = new Model(); Assert.False(model.IsValid("Value2")); }
/// <summary> /// Search availability using online business logic /// </summary> /// <param name="onlineAvailabilitySearchCriteria">search criteria to use</param> /// <returns>Available rooms found</returns> public AvailabilitySearchResult CheckOnlineAvailability(Model.Room.Online.AvailabilitySearchCriteria onlineAvailabilitySearchCriteria) { Logger.LogInfo("==========CheckOnlineAvailability Called=========="); Logger.LogDebugAsXml(onlineAvailabilitySearchCriteria); AvailabilitySearchResult searchResults = null; var businessIds = new List<long>(); var currency = onlineAvailabilitySearchCriteria.RequestedCurrency; foreach (var shortName in onlineAvailabilitySearchCriteria.BusinessShortNames) { // will need to send the list of businesses in future CachedBusinessDigest currentBusiness = Cache.Cache.BusinessByShortName.TryGetValue(shortName); if (currentBusiness != null) { businessIds.Add(currentBusiness.Id); if (currency == null || String.IsNullOrEmpty(currency)) { currency = currentBusiness.WorkingCurrencyCode; } } } if (businessIds.Any()) { // Check that is not in the past onlineAvailabilitySearchCriteria.IsValid(); if (onlineAvailabilitySearchCriteria.RoomSearchCriteria == null || onlineAvailabilitySearchCriteria.RoomSearchCriteria.Count == 0) { onlineAvailabilitySearchCriteria.RoomSearchCriteria = new List<Model.Room.Online.RoomRestrictions> { new Model.Room.Online.RoomRestrictions {NumberOfAdults = null, NumberOfChildren = null} }; } Model.Room.Online.RoomRestrictions firstRestriction = onlineAvailabilitySearchCriteria.RoomSearchCriteria[0]; Channel channel = channelDao.GetChannelByShortName(onlineAvailabilitySearchCriteria.ChannelShortName); if (channel == null) { // Exception since this is online search source and channel id is required. return GetNullBusinessAvailabilityResult(onlineAvailabilitySearchCriteria); } // Set up search criteria AvailabilitySearchCriteria searchCriteria = new AvailabilitySearchCriteria { StartDate = onlineAvailabilitySearchCriteria.StartDate, EndDate = onlineAvailabilitySearchCriteria.EndDate, NumberOfAdults = firstRestriction.NumberOfAdults, NumberOfChildren = firstRestriction.NumberOfChildren, BusinessIds = businessIds, ChannelId = channel.Id, RequestedCurrency = currency }; // Do search here searchResults = CheckAvailability(searchCriteria); } else { // No businesses found so return null result for it searchResults = GetNullBusinessAvailabilityResult(onlineAvailabilitySearchCriteria); } var results = FilterSearchResultsForOnlineCheckAvailability(searchResults); Logger.LogInfo("==========CheckOnlineAvailability Returns=========="); Logger.LogDebugAsXml(results); return results; }