public BaseResponse UpdateProduct(ProductModelRequest entity) { try { var productEntity = entity.MapTo <ProductEntity>(); var productmodel = productRepository.GetProduct(productEntity.ProductId); if (productmodel == null) { return new BaseResponse { IsSuccess = false, Msg = "can not find mddel" } } ; bool result = productRepository.UpdateProduct(productmodel); return(result ? new BaseResponse { IsSuccess = true } : new BaseResponse { IsSuccess = false }); } catch (Exception ex) { return(new BaseResponse { IsSuccess = false, Msg = ex.Message }); } }
public BaseResponse DeleteProduct(ProductModelRequest entity) { try { var productEntity = entity.MapTo<ProductEntity>(); productRepository.DeleteProduct(productEntity); return new BaseResponse { IsSuccess = true }; } catch (Exception ex) { return new BaseResponse { IsSuccess = false, Msg = ex.Message }; } }
public ProductModelResponse AddProduct(ProductModelRequest entity) { try { var productEntity = entity.MapTo<ProductEntity>(); long id = productRepository.AddProduct(productEntity); return id > 0 ? new ProductModelResponse { ProductId = id, IsSuccess = true } : new ProductModelResponse { IsSuccess = false, ProductId = 0 }; } catch(Exception ex) { return new ProductModelResponse { ProductId = 0, IsSuccess = false, Msg = ex.Message }; } }
public BaseResponse DeleteProduct(ProductModelRequest entity) { try { var productEntity = entity.MapTo <ProductEntity>(); productRepository.DeleteProduct(productEntity); return(new BaseResponse { IsSuccess = true }); } catch (Exception ex) { return(new BaseResponse { IsSuccess = false, Msg = ex.Message }); } }
public BaseResponse UpdateProduct(ProductModelRequest entity) { try { var productEntity = entity.MapTo<ProductEntity>(); var productmodel = productRepository.GetProduct(productEntity.ProductId); if (productmodel == null) return new BaseResponse { IsSuccess = false, Msg = "can not find mddel" }; bool result = productRepository.UpdateProduct(productmodel); return result ? new BaseResponse { IsSuccess = true } : new BaseResponse { IsSuccess = false}; } catch (Exception ex) { return new BaseResponse { IsSuccess = false, Msg = ex.Message }; } }
public ProductModelResponse AddProduct(ProductModelRequest entity) { try { var productEntity = entity.MapTo <ProductEntity>(); long id = productRepository.AddProduct(productEntity); return(id > 0 ? new ProductModelResponse { ProductId = id, IsSuccess = true } : new ProductModelResponse { IsSuccess = false, ProductId = 0 }); } catch (Exception ex) { return(new ProductModelResponse { ProductId = 0, IsSuccess = false, Msg = ex.Message }); } }