public void UpdatePrice(Guid id, Decimal price) { Data.Models.Products product = productRepository.GetById(id); product.Price = price; product.SalePrice = price + ((price * 10) / 100); productRepository.Edit(product); }
private ProductModel MapProductToProductModel(Data.Models.Products product) { ProductModel prod = new ProductModel(); prod.Id = product.Id; prod.Name = product.Name; prod.Description = product.Description; prod.Price = product.Price; prod.SalePrice = product.SalePrice; prod.ImageUrl = product.ImageUrl; prod.CreatedBy = product.CreatedBy; prod.CreatedOn = product.CreatedOn; prod.UpdatedBy = product.UpdatedBy; prod.UpdatedOn = product.UpdatedOn; prod.IsActive = product.IsActive; return(prod); }
private Data.Models.Products MapProductModelToProduct(ProductModel product, bool isAdd = true) { Data.Models.Products productEntity = new Data.Models.Products(); productEntity.Id = product.Id; productEntity.Name = product.Name; productEntity.Description = product.Description; productEntity.Price = product.Price; productEntity.SalePrice = product.Price + ((product.Price * 10) / 100); productEntity.ImageUrl = product.ImageUrl; productEntity.UpdatedBy = product.UpdatedBy; productEntity.UpdatedOn = DateTime.Now; productEntity.IsActive = product.IsActive; if (isAdd) { productEntity.CreatedBy = product.CreatedBy; productEntity.CreatedOn = DateTime.Now; } else { productEntity.CreatedBy = product.CreatedBy; productEntity.CreatedOn = product.CreatedOn; } return(productEntity); }
public ProductModel GetById(Guid id) { Data.Models.Products product = productRepository.GetById(id); return(MapProductToProductModel(product)); }