public async Task ServerSideValidation(AccessRight obj) { TryValidateModel(obj); ModelState.Remove("Role.LocalizedName"); ModelState.Remove("Role.DefaultControllerName.Name"); var cntrlExist = await DbContext.ControllersNames .AnyAsync(c => c.Name.Equals(obj.Controller.Name)); if (!cntrlExist) { ModelState.AddModelError("ControllerName", "Выбранная страница не существует"); } var role = await RoleMngr.FindByNameAsync(obj.Role.Name); if (role == null) { ModelState.AddModelError("Role", "Выбранная роль не существует"); } if (!ActionName.Equals(nameof(Change))) { var accessRightExisting = DbContext.AccessRights.Include("Role") .FirstOrDefault(ar => ar.Role.Name.Equals(obj.Role.Name) && ar.Controller.Name.Equals(obj.Controller.Name)); if (accessRightExisting != null) { ModelState.AddModelError("", "Правило для этой роли и страницы уже есть, измените его"); } } }
public async Task ServerSideValidation(Tariff obj) { TryValidateModel(obj); var isTariffExist = await DbContext.Tariffs .AnyAsync(t => t.Name.Equals(obj.Name)); if (ActionName.Equals(nameof(Create))) { if (isTariffExist) { ModelState.AddModelError("Name", "Такое название тарифа уже существует, выберите другое"); } } else { var tariffExisting = await DbContext.Tariffs .FirstOrDefaultAsync(t => t.Id.Equals(obj.Id)); if (!tariffExisting.Name.Equals(obj.Name) && isTariffExist) { ModelState.AddModelError("Name", "Такое название тарифа уже существует, выберите другое"); } } }
public bool Equals(UrlModel urlModel) { if (urlModel == null) { return(false); } return(((string.IsNullOrEmpty(AreaName) && string.IsNullOrEmpty(urlModel.AreaName)) || (string.Equals(AreaName, urlModel.AreaName, StringComparison.InvariantCultureIgnoreCase))) && ((string.IsNullOrEmpty(ControllerName)) || (ControllerName.Equals(urlModel.ControllerName, StringComparison.InvariantCultureIgnoreCase)) && ((ActionName == null) || ActionName.Equals(urlModel.ActionName, StringComparison.InvariantCultureIgnoreCase)))); }
private void SaveOrUpdate() { NoteValidator validator = new NoteValidator(); var validationResult = validator.Validate(Note); if (validationResult.IsValid) { if (ActionName.Equals("Save")) { Note note = new Note { Title = Note.Title, Content = Note.Content, CreatedDate = DateTime.Now, UpdatedDate = DateTime.Now, UserId = _loggedInUser.Id }; UnitOfWork.Notes.Add(note); } else { Note foundNote = UnitOfWork.Notes.SingleOrDefault(n => n.Id == Note.Id); foundNote.Title = Note.Title; foundNote.Content = Note.Content; foundNote.UpdatedDate = DateTime.Now; } if (UnitOfWork.Complete() > 0) { MessageBox.Show($"Note Title: '{Note.Title}' {ActionName.ToLower()}d.", $"Note {ActionName}", MessageBoxButton.OK, MessageBoxImage.Information); NavigateNotesPage(); } else { ErrorText = $"Note could not {ActionName.ToLower()}d."; } } else { // show first error message ErrorText = validationResult.Errors[0].ErrorMessage; } }
public async Task ServerSideValidation(Role obj) { TryValidateModel(obj); var checkingNamePattern = @"^[a-z]*$"; if (!Regex.IsMatch(obj.Name, checkingNamePattern)) { ModelState.AddModelError("Name", "Название должно быть маленькими латинскими буквами"); } var isControllerExist = await DbContext .ControllersNames.AnyAsync(c => c.Name.Equals(obj.DefaultControllerName.Name)); if (!isControllerExist) { ModelState.AddModelError("DefaultControllerName", "Такой страницы не существует"); } var isRoleExist = await DbContext .Roles.AnyAsync(r => r.Name.Equals(obj.Name)); if (ActionName.Equals(nameof(Create)) && isRoleExist) { ModelState.AddModelError("Name", "Такая роль уже существует"); } else { var oldRole = await DbContext .Roles.FirstOrDefaultAsync(r => r.Name.Equals(obj.Id)); if (oldRole.Name.Equals(obj.Name)) { ModelState.AddModelError("Name", "Такая роль уже существует"); } } }
public override bool ShouldViewApply(CommercePipelineExecutionContext context, EntityView entityView, TEntity entity) { return(ActionName.Equals(entityView.Action, StringComparison.OrdinalIgnoreCase)); }
public HtmlString RenderSubMenuItem(string functionName, string text, string actionName, string controllerName = null, object routeValues = null, object htmlAtts = null) { string format = @"<li><a href=""{URL}"" {ATTR}>{TEXT}</a></li>"; if (ControllerName.Equals(controllerName, StringComparison.InvariantCultureIgnoreCase) && ActionName.Equals(actionName, StringComparison.InvariantCultureIgnoreCase)) { return(RenderItemFormat(functionName, format, text, actionName, controllerName, routeValues, htmlAtts, "active")); } return(RenderItemFormat(functionName, format, text, actionName, controllerName, routeValues, htmlAtts)); }
public bool MatchesName(string actionName) { return(ActionName.Equals(actionName, StringComparison.InvariantCultureIgnoreCase)); }
public async Task ServerSideValidation(Profile obj, string roleName, int tariffId) { TryValidateModel(obj); ModelState.Remove("Tariff.Name"); var isUserNameExist = await _dbContext.Users .AnyAsync(u => u.UserName.Equals(obj.Account.UserName)); var isEmailExist = await _dbContext.Users .AnyAsync(u => u.Email.Equals(obj.Account.Email)); if (ActionName.Equals(nameof(Create))) { if (isUserNameExist) { ModelState.AddModelError("Account.UserName", "Введённый логин уже существует, выберите другой"); } if (isUserNameExist) { ModelState.AddModelError("Account.Email", "Введённый почтовый адрес уже сущесвует, выберите другой"); } } else { var oldAccount = await _dbContext.Users .FirstOrDefaultAsync(u => u.Id.Equals(obj.Account.Id)); if (oldAccount != null) { if (!oldAccount.UserName.Equals(obj.Account.UserName) && isUserNameExist) { ModelState.AddModelError("Account.UserName", "Введённый логин уже существует, выберите другой"); } if (!oldAccount.Email.Equals(obj.Account.Email) && isEmailExist) { ModelState.AddModelError("Account.Email", "Введённый почтовый адрес уже сущесвует, выберите другой"); } } else { ModelState.AddModelError("", "Аккаунт профиля не найден"); } } var pattern = @"^(?=.*[a-z0-9])[a-z][a-z\d.-]{0,19}$"; var regexCheck = Regex.IsMatch(obj.Account.UserName, pattern); if (!regexCheck) { ModelState.AddModelError("Account.UserName", "Логин должен соответствовать латинским маленьким буквам и быть не длинее 19 символов"); } var isTariffExist = await _dbContext.Tariffs .AnyAsync(t => t.Id.Equals(tariffId)); if (!isTariffExist) { ModelState.AddModelError("Tariff", "Выбранного тарифа не существует"); } var isRoleExist = await _dbContext.Roles .AnyAsync(r => r.Name.Equals(roleName)); if (!isRoleExist) { ModelState.AddModelError("", "Выбранной роли не существует"); } }
/// <summary> /// Indicates whether the current object is equal to another object of the same type. /// </summary> /// <returns> /// true if the current object is equal to the <paramref name="other"/> parameter; otherwise, false. /// </returns> /// <param name="other">An object to compare with this object.</param> public bool Equals(ServiceInput other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return(string.Equals(Name, other.Name) && RequiredField.Equals(other.RequiredField) && (ActionName?.Equals(other.ActionName) ?? true) && EmptyIsNull.Equals(other.EmptyIsNull)); }
public virtual void OnGUI() { EditorGUILayout.Space(); using (new EditorHelper.Box(true, 0)) { using (new EditorHelper.Indent(-4)) using (new EditorHelper.Horizontal()) { enabled = EditorGUILayout.Toggle(enabled, GUILayout.ExpandWidth(false), GUILayout.Width(15)); bool existed = Config.actionFold.ContainsKey(this); if (!existed) { Config.actionFold[this] = true; } bool foldout = Config.actionFold[this]; GUIStyle gs = new GUIStyle(EditorStyles.foldout); GUIStyleState normal = new GUIStyleState(); normal.textColor = new Color(226 / 255f, 100 / 255f, 226 / 255f, 1); gs.fontStyle = FontStyle.Bold; gs.normal = normal; gs.focused = normal; gs.hover = normal; gs.active = normal; gs.onActive = normal; gs.onFocused = normal; gs.onHover = normal; gs.onNormal = normal; foldout = GUILayout.Toggle( foldout, $"{GetTitleText()}", gs, GUILayout.ExpandWidth(false), GUILayout.Width(150) ); if (Config.actionFold[this] != foldout) { Config.ResetCacheRectData(); } Config.actionFold[this] = foldout; if (!foldout) { return; } IsRemoved = GUILayout.Button("Remove", GUILayout.Width(80)); if (GUILayout.Button("Copy", GUILayout.Width(80))) { copiedAction = this; } IsPasted = GUILayout.Button("Paste", GUILayout.Width(80)); } using (new EditorHelper.Indent(-3)) { ActionLayer layer = ShowActionLayer(); layer = (ActionLayer)EditorGUILayout.EnumPopup("Active Layer", layer); actionLayer = layer.ToString(); if (!Config.showSpawnerMode) { ActionName oldActionName = ShowActionName(); ActionName newActionName = (ActionName)EditorGUILayout.EnumPopup( "Action Name", oldActionName); actionName = newActionName.ToString(); IsActionChanged = !oldActionName.Equals(newActionName); } ActionTriggerCondition oldCondition = ShowTriggerCondition(); ActionTriggerCondition newCondition = (ActionTriggerCondition)EditorGUILayout.EnumPopup("Trigger Condition", oldCondition); triggerCondition = newCondition.ToString(); if (newCondition == ActionTriggerCondition.Time) { waitTime = EditorGUILayout.FloatField("Activate at(s)", waitTime); waitTime = Mathf.Max(0, waitTime); } else if (newCondition == ActionTriggerCondition.ByEvent) { eventId = EditorGUILayout.IntField("Event ID", eventId); } else if (newCondition == ActionTriggerCondition.OnWaveFinish) { waveOrder = EditorGUILayout.IntField("Wave Order", waveOrder); waveOrder = Mathf.Max(1, waveOrder); } DrawGUI(); } } }