public void Add(Product product) { //AOP Aspect Oriented Programming // ValidationTool.FluentValidate(new ProductValidator(), product); // Business rules _productDal.Add(product); }
public IResult Add(Product product) { IResult result = BusinessRules.Run(CheckIfProductNameExist(product.ProductName), CheckIfProductCountOfCategoryCorrect(product.CategoryId), CheckIfCategoryLimitExcedeed()); //validation if (result != null) { return(result); } _productDal.Add(product); return(new SuccessResult(Messages.ProductAdded)); // ValidationTool.Validate(new ProductValidator(), product); }
public IResult Add(Product product) { //REFACTORY //ValidationTool.Validate(new ProductValidator(), product); //List<Product> listOfProduct = new List<Product>(); //var res = _productDAL.GetAll(p => p.CategoryID == product.CategoryID).Count; //foreach (var item in listOfProduct) //{ //if (res > 10) //{ // return new ErrorResult(Messages.ProductCountOfCategoryError); //} //} //if (product.ProductName.Length < 2) //{ // return new ErrorResult(Messages.ProductNameInvalid); //} ////business codes //_productDAL.Add(product); //return new SuccessResult(Messages.ProductAdded);//set vermediğim için ctor da eklemem lazım IResult result = BusinessRules.Run(CheckIfProductNameExist(product.ProductName), CheckIfProductCountOfCategoryCorrect(product.CategoryID), CheckIfCategoryCountCorrect()); if (result != null) { return(result); } _productDAL.Add(product); return(new SuccessResult(Messages.ProductAdded));//set vermediğim için ctor da eklemem lazım //if (CheckIfProductCountOfCategoryCorrect(product.ProductID).Success && CheckIfProductNameExist(product.ProductName).Success) //{ // _productDAL.Add(product); // return new SuccessResult(Messages.ProductAdded);//set vermediğim için ctor da eklemem lazım //} //return new ErrorResult(); }
public ActionResult Add(VMProduct model) { Product yeniUrun = new Product(); ProductModel pm = ProductModelDAL.Get(x => x.ModelID == model.ModelID); yeniUrun.ModelID = pm.ModelID; yeniUrun.Description = model.Description; yeniUrun.IsActive = true; yeniUrun.ProductID = Guid.NewGuid(); yeniUrun.ProductName = model.ProductName; yeniUrun.UnitPrice = model.UnitPrice; yeniUrun.UnitsInStock = model.UnitsInStock; yeniUrun.ViewCount = 0; Guid cID = pm.CategoryID; Category c = CategoryDAL.Get(x => x.CategoryID == cID); foreach (Property item in c.Properties) { string valProp = Request.Form[item.PropertyID.ToString()]; if (valProp != null) { ProductTechnicProperty temp = new ProductTechnicProperty(); temp.PropertyID = item.PropertyID; temp.PropertyValue = valProp; temp.ProductPropertyID = Guid.NewGuid(); yeniUrun.ProductTechnicProperties.Add(temp); } } foreach (HttpPostedFileBase item in model.Picture) { if (item != null) { string pic = System.IO.Path.GetFileName(item.FileName); string path = System.IO.Path.Combine(Server.MapPath("~/Assets/img/products"), pic); // file is uploaded item.SaveAs(path); ProductPicture temp = new ProductPicture(); temp.ProductPictureID = Guid.NewGuid(); temp.PicturePath = item.FileName; temp.IsActive = true; yeniUrun.ProductPictures.Add(temp); } } ProductDAL.Add(yeniUrun); return(RedirectToAction("Add")); }
public void Add(Product product) { //ProductValidator productValidator = new ProductValidator(); //var result = productValidator.Validate(product); //if (result.Errors.Count>0) //{ // throw new ValidationException(result.Errors); //} ValidationTool.Validate(new ProductValidator(), product); _productDAL.Add(product); }
public async Task <IResult> CreateProduct(CreateProductDto productDto) { Product product = new Product { BrandId = productDto.BrandId, CanNotable = productDto.CanNotable, CategoryId = productDto.CategoryId, Description = productDto.Description, DiscountRate = productDto.DiscountRate, InStock = productDto.InStock, IsNew = productDto.IsNew, IsPopular = productDto.IsPopular, Name = productDto.Name, Price = productDto.Price }; product = _productDAL.Add(product); foreach (var colorId in productDto.ColorIds) { product.ProductColors.Add(new ProductColor(product.Id, colorId)); } if (productDto.DemandTypeIds != null && productDto.DemandTypeIds.Count() != 0) { foreach (var demandTypeId in productDto.DemandTypeIds) { product.ProductDemands.Add(new ProductDemand(product.Id, demandTypeId)); } } if (productDto.Images != null && productDto.Images.Count() > 0) { foreach (var image in productDto.Images) { string imageName = Guid.NewGuid() + "." + image.FileName.Split('.')[1]; var fileLocate = $"{productDto.FilePath}/{imageName}"; product.ProductImages.Add(new ProductImage { ImageName = imageName, ProductId = product.Id }); using (var stream = new FileStream(fileLocate, FileMode.Create)) { image.CopyTo(stream); } } } int result = await _uow.Complete(); return(ResultHelper <int> .ResultReturn(result)); }
public IActionResult Add(Product entity) { Product added = _productDal.Add(entity); if (added != null && added.Id > 0) { return(Ok(added)); } else { return(BadRequest("Ekleme işlemi başarısız oldu!")); } }
public IResult Add(Product product) { IResult result = BusinessRules.Run(CheckProductName(product.ProductName), ChechIfProductCountOfCategoryCorrect(product.CategoryId), CheckIfCategoryLimitExceded()); if (result != null) { return(result); } _Iproductdal.Add(product); return(new SuccessResult(Messages.ProductAdded)); }
public IResult Add(Product product) { IResult result = BusinessRules.Run(CheckIfProductNameExists(product.ProductName), ChecktIfProductCountOfCategoryCorrect(product.CategoryID), CheckIfCategoryLimitExceded()); if (result != null) { return(result); } _productDAL.Add(product); return(new SuccessResult()); }
public IResult Add(Product product) { var result = BusinessRules.Run( CheckIfHaveAlreadySameProductName(product.ProductName), CheckIfHaveAlreadySameProductType(product.ProductType) ); if (result != null) { return(result); } _productDAL.Add(product); return(new SuccessResult("Successfully Added")); }
//[RemoveCache] //[Transaction] // örn. hata olursa geri al //[Performance] // örn. çalışması 5sn geçerse uyar public IResult Add(Product product) { // Business codes // Validation // üst 2si AYRI olmalı! // fluent validation ile bu doğrulamaları yapıp burdan kaldırıcaz. : product.UnitPrice <= 0, product.ProductName.Length < 2 vs hep validation // Business. add folder : ValidationRules : ProductValidator yazdık.. Aşağıyı kapat. ////if (product.UnitPrice <= 0) ////{ //// return new ErrorResult(Messages.UnitPriceInvalid); ////} ////if (product.ProductName.Length < 2) ////{ //// // magic string : öyle elle metinsel standardı olmayan şeyler //// // return new ErrorResult("Ürün ismi en az 2 karakter olmalıdır"); //// return new ErrorResult(Messages.ProductNameInvalid); ////} /// //var context = new ValidationContext<Product>(product); //ProductValidator productValidator = new ProductValidator(); //var result = productValidator.Validate(context); //if (!result.IsValid) //{ // throw new ValidationException(result.Errors); //} // üsttekinin yerine //ValidationTool.Validate(new ProductValidator(), product); // 1e1 aynı anlam attribute artık : [ValidationAspect(typeof(ProductValidator)] // Loglama // Cacheremove // performance // transaction // authorization //...... > bunlar iş mantığı değil.. buraya eklenirlerse de burası ÇORBA : AOP> attribute ekleyerek!!örn. method üstüne [ValidationAspect(typeof(ProductValidator)] IResult result = BusinessRules.Run(CheckIfProductCountOfCategoryCorrect(product.CategoryId), CheckIfProductNameExists(product.ProductName)); if (result != null) { return(result); } _productDAL.Add(product); return(new SuccessResult(Messages.ProductAdded)); }
public IResult Add(Product product) { //business vs validation : iş kuralları ayrı doğrulama ayrı olmalıdır //if (product.ProductName.Length<2) //{ // //magic strings // return new ErrorResult(Messages.ProductNameInvalid); //} //ValidationTool.Validate(new ProductValidator(),product); IResult result = BusinessRules.Run(CheckIfProductCountOfCategoryCorrect(product.CategoryId), CheckIfProductNameExists(product.ProductName), CheckIfCategoryLimitExceded()); if (result != null) { return(result); } _productDAL.Add(product); return(new SuccessResult(Messages.ProductAdded)); }
//[FluentValidationAspect(typeof(ProductValidator))] public Product Add(Product product) { return(_productDal.Add(product)); }
public bool Add(Product entity) { return(_productDAL.Add(entity) > 0); }
public IResult Add(Product product) { //Business codes _productDAL.Add(product); return(new SuccessResult(Messages.ProductAdded)); }
public void Add(Product product) { ValidationTool.Validate(new ProductValidator(), product); _productDAL.Add(product); }
public IResult Add(Product product) { _productDal.Add(product); // validasyon kodları, iş kodları vs. buraya çağrılacak return(new SuccessResult(Messages.ProductAdded)); }
public void Insert(Product entity) { _dal.Add(entity); }
public static int Add(Product data) { return(ProductDB.Add(data)); }
public IResult Add(Product product) { _productDal.Add(product); return(new SuccessResult(Messages.ProductAdded)); }
public void createProduct(Products product) { _productDAL.Add(product); }
public void Insert(Product entity) { _product.Add(entity); }
public void AddProduct(Product model) { _productDAL.Add(model); }
public void Add(Product product) { productDAL.Add(product); }
public Product Add(Product product) { //ValidatorTool.FluentValidate(new ProductValidatior(), product); return(_productDal.Add(product)); }
public void AddProduct(Product product) { _productDAL.Add(product); }
public void Add(Product product) { _productDal.Add(product); }
/// <summary> /// 新增产品 /// </summary> /// <param name="entity"></param> /// <returns></returns> public int AddProduct(TblAdProductV2 entity) { return(productDAL.Add(entity)); }
public ResponseModel <Product> Add(Product entity) { responseModel.Success = _productDAL.Add(entity); responseModel.result = entity; return(responseModel); }
public void Add(Products entity) { _ProductDAL.Add(entity); }