public Task HandleAsync(UpdateMediaCommand command) { var phoneId = Convert.ToInt32(_httpContextAccessor.HttpContext.Request.RouteValues["Id"]); var mediaResult = _mediaRepository .GetAll() .Where(m => m.PhoneId == phoneId); MediaValidator.Validate(mediaResult); int mediaResultIndex = 0; foreach (Media media in mediaResult) { for (int i = mediaResultIndex; i < mediaResult.Count();) { media.Photo = command.Media[i].Photo; media.Video = command.Media[i].Video; _mediaRepository.Update(media); mediaResultIndex++; break; } } return(Task.CompletedTask); }
public Task <PhoneMediaResonse> HandleAsync(PhoneMediaQuery query) { var media = _mediaRepository .GetAll() .Where(m => m.PhoneId == query.Id); MediaValidator.Validate(media); return(Task.FromResult(new PhoneMediaResonse { Media = _mapper.Map <List <PhoneMediaViewModel> >(media) })); }
public Task HandleAsync(DeleteMediaCommand command) { var phoneId = Convert.ToInt32(_httpContextAccessor.HttpContext.Request.RouteValues["Id"]); var medias = _mediaRepository .GetAll() .Where(m => m.PhoneId == phoneId); MediaValidator.Validate(medias); foreach (Media m in medias) { _mediaRepository.Delete(m); } return(Task.CompletedTask); }
public MediaValidatorFacts() { _mediaValidator = new MediaValidator(); }
public MediaValidatorTests() { _mediaValidator = new MediaValidator(); }
/// <summary> /// Method to validate model /// </summary> /// <returns>Returns the result of validation</returns> protected override FluentValidation.Results.ValidationResult Validate() { var validator = new MediaValidator(); return(validator.Validate(this)); }