public async Task <CreateResponse> Create(Create data) { var validator = new CreateValidator(); var validResult = validator.Validate(data); if (validResult.IsValid) { var url = _routes[_create]; var sender = new Sender <Create, CreateResponse>(); var result = await sender.Post(data, url); if (result != null) { //if (result.Err != null) //{ // LogResultError(url, result.Err); //} } else { // Logger.Error("Could't recive data. Check internet connection."); } return(result); } else { var errors = validResult.Errors; LogErrors(errors); } return(null); }
public void Validate_ValidQuery_ShouldReturnTrue(string query) { var validator = new CreateValidator(new Database()); var actual = validator.Validate(query); Assert.True(actual); }
public IActionResult Create(CategoryCreateVM vm) { var model = _createValidator.Validate(vm); if (model.IsValid) { _mappedCategory.AddMappedCategory(vm); _mappedCategory.Save(); return(RedirectToAction(nameof(Index))); } return(View(vm)); }
public IActionResult Create(PostCreateVM vm, Guid[] categories) { var model = _createValidator.Validate(vm); if (model.IsValid) { _mappedPost.AddMappedPost(vm, categories); _mappedPost.Save(); return(RedirectToAction(nameof(Index))); } return(View(vm)); }
public void IsValid_ShouldBe_True_When_Quantity_Is_Positive(Create c) { c.Quantity = 1; _validator.Validate(c).IsValid.ShouldBeTrue(); }
public void Validate_InvalidQuery_ShouldThrowAnException(string query) { var validator = new CreateValidator(new Database()); Assert.ThrowsAny <Exception>(() => validator.Validate(query)); }