public bool UpdateProductAvailabilityPrice(ProductEL productEL) { bool isProductAvailabilityUpdated = false; try { Product product = new Product(); using (uow = new UnitOfWork.UnitOfWork()) { product = uow.ProductRepository.GetById(productEL.ProductID); product.IsAvailable = productEL.IsAvailable; product.Price = productEL.Price; uow.ProductRepository.Update(product); uow.Save(); isProductAvailabilityUpdated = true; } } catch { isProductAvailabilityUpdated = false; } return(isProductAvailabilityUpdated); }
public AddProductResponse AddProduct(AddProductRequest request) { AddProductResponse addProductResponse = new AddProductResponse(); addProductResponse.Message = "Product not added successfully."; if (String.IsNullOrEmpty(request.AuthToken)) { addProductResponse.Message = "Please pass all mandatory fields."; return(addProductResponse); } AuthenticationToken authToken = new Helper().GetAuthenticationToken(request.AuthToken); if (authToken == null) { addProductResponse.Message = "Unauthorizes user."; return(addProductResponse); } if (String.IsNullOrEmpty(request.productInfo.Name) || String.IsNullOrEmpty(request.productInfo.Quantity)) { addProductResponse.Message = "Please pass all mandatory fields."; return(addProductResponse); } ProductEL productEL = new ProductEL(); productEL = MapperUtility.MapTo(request.productInfo, productEL); if (productHelper.AddProduct(productEL)) { addProductResponse.Message = "Product added successfully."; addProductResponse.IsSuccess = true; return(addProductResponse); } else { addProductResponse.Message = "Some error occured."; return(addProductResponse); } }
public bool AddProduct(ProductEL productEL) { bool isProductAdded = false; try { Product product = new Product(); product = MapperUtility.MapTo(productEL, product); using (uow = new UnitOfWork.UnitOfWork()) { uow.ProductRepository.Insert(product); uow.Save(); isProductAdded = true; } } catch { isProductAdded = false; } return(isProductAdded); }