public IActionResult CreateDuplicateRule(EditDuplicateRuleModel model) { if (ModelState.IsValid) { var entity = new DuplicateRule(); model.CopyTo(entity); entity.DuplicateRuleId = Guid.NewGuid(); entity.CreatedBy = CurrentUser.SystemUserId; var conditions = new List <DuplicateRuleCondition>(); int i = 0; foreach (var item in model.AttributeId) { var cd = new DuplicateRuleCondition { DuplicateRuleConditionId = Guid.NewGuid(), DuplicateRuleId = entity.DuplicateRuleId, EntityId = model.EntityId, IgnoreNullValues = model.IgnoreNullValues[i], IsCaseSensitive = model.IsCaseSensitive[i], AttributeId = item }; conditions.Add(cd); i++; } entity.Conditions = conditions; _duplicateRuleCreater.Create(entity); return(CreateSuccess(new { id = entity.DuplicateRuleId })); } var msg = GetModelErrors(ModelState); return(CreateFailure(msg)); }