public async Task <string> DeleteCategory(int id) { try { using var sqlCon = new SqlConnection(_options.connectionString); await sqlCon.OpenAsync(); var dynamicParameters = new DynamicParameters(); dynamicParameters.Add("@id", id); var res = new CategoryResponse(); await sqlCon.ExecuteAsync( "spDeleteCategory", dynamicParameters, commandType : CommandType.StoredProcedure ); return(res.Messages = Enumhelper.GetEnumDescription(StatusHandlersEnum.StatusHandle.DeleteSuccess)); } catch (Exception ex) { var res = new CategoryResponse(); return(res.Messages = ex.Message); } }
public async Task <string> AddProductCategory(ProductCategoryRequest request) { try { using var sqlCon = new SqlConnection(_options.connectionString); await sqlCon.OpenAsync(); var dynamicParameters = new DynamicParameters(); dynamicParameters.Add("@productId", request.ProductId); dynamicParameters.Add("@categoryId", request.CategoryId); var res = new ProductCategoryResponse(); await sqlCon.ExecuteAsync( "spAddProductCategory", dynamicParameters, commandType : CommandType.StoredProcedure); return(res.Messages = Enumhelper.GetEnumDescription(StatusHandlersEnum.StatusHandle.CreateSuccess)); } catch (Exception ex) { var res = new ProductCategoryResponse(); return(res.Messages = ex.Message); } }
public async Task <string> UpdateBrand(BrandRequest request) { try { using var sqlCon = new SqlConnection(_options.connectionString); await sqlCon.OpenAsync(); var parameters = new DynamicParameters(); parameters.Add("@BrandId", request.Id); parameters.Add("@BrandName", request.Name); var res = new BrandResponse(); await sqlCon.ExecuteAsync( "spUpdateBrand", parameters, commandType : CommandType.StoredProcedure); return(res.Messages = Enumhelper.GetEnumDescription(StatusHandlersEnum.StatusHandle.UpdateSuccess)); } catch (Exception ex) { var res = new BrandResponse(); return(res.Messages = ex.Message); } }