Ejemplo n.º 1
0
        public ActionResult Add(Genre model)
        {
            var validator = new GenreValidator(_unitOfWork).Validate(model);

            if (validator.IsValid)
            {
                _unitOfWork.GetRepo <Genre>().Add(model);
                bool IsSuccess = _unitOfWork.Commit();

                if (IsSuccess)
                {
                    return(RedirectToAction("List"));
                }

                ViewBag.IsSuccess = IsSuccess;
                ViewBag.Message   = "Tekrar Deneyiniz";
                return(View());
            }


            validator.Errors.ToList().ForEach(a =>
            {
                ModelState.AddModelError(a.PropertyName, a.ErrorMessage);
            });

            return(View());
        }
Ejemplo n.º 2
0
        public ActionResult Edit(Genre guncel)
        {
            var validator = new GenreValidator(_unitOfWork).Validate(guncel);

            if (validator.IsValid)
            {
                var model = _unitOfWork.GetRepo <Genre>().GetObject(x => x.Id == guncel.Id);
                model.Name        = guncel.Name;
                model.Description = guncel.Description;
                _unitOfWork.GetRepo <Genre>().Update(guncel);
                bool IsSuccess = _unitOfWork.Commit();
                if (IsSuccess)
                {
                    return(RedirectToAction("List"));
                }
                else
                {
                    ViewBag.IsSuccess = IsSuccess;
                    ViewBag.Message   = "tekrar deneyin";
                    return(View());
                }
            }

            validator.Errors.ToList().ForEach(a =>
            {
                ModelState.AddModelError(a.PropertyName, a.ErrorMessage);
            });

            return(View());
        }
Ejemplo n.º 3
0
        private void Name_Validating(object sender, CancelEventArgs e)
        {
            var validator = new GenreValidator();
            var result    = validator.NameCheck(txtName.Text);

            errorProviderName.SetError(txtName, result.Message);
            e.Cancel = !result.IsValid;
        }
Ejemplo n.º 4
0
 public EfAddGenre(MovieReviewContext context, IMapper mapper, GenreValidator validator)
 {
     this.context   = context;
     this.mapper    = mapper;
     this.validator = validator;
 }
 public GenreValidatorTests()
 {
     _fixtue = new Fixture();
     _validator = new GenreValidator();
 }
 public GenreValidatorTests()
 {
     _fixtue    = new Fixture();
     _validator = new GenreValidator();
 }
 public EfCreateGenreCommand(MovieContext context, GenreValidator validator)
 {
     this.context   = context;
     this.validator = validator;
 }
Ejemplo n.º 8
0
 public void Setup()
 {
     _validator = new GenreValidator();
 }