public SaveProductRes SaveProduct(SaveProductReq saveProductReq) { var result = new SaveProductRes() { Result = 0, Message = $"Đã xảy ra lỗi, vui lòng thử lại sau." }; try { DynamicParameters parameters = new DynamicParameters(); parameters.Add(@"ID", saveProductReq.ID); parameters.Add(@"ProductName", saveProductReq.ProductName); parameters.Add(@"BrandID", saveProductReq.BrandID); parameters.Add(@"CategoryID", saveProductReq.CategoryID); parameters.Add(@"Price", saveProductReq.Price); var response = SqlMapper.ExecuteScalar <int>(con, "proc_SaveProduct", param: parameters, commandType: CommandType.StoredProcedure); result.Result = response; result.Message = saveProductReq.ID != 0 ? $"Sản phẩm đã được tạo thành công." : $"Sản phẩm đã được cập nhật thành công"; return(result); } catch (Exception ex) { return(result); } }
public async Task <SaveProductRes> Save(SaveProductReq request) { var result = new SaveProductRes() { ProductId = 0, Message = "Something went wrong, please contact administrator." }; try { DynamicParameters parameters = new DynamicParameters(); parameters.Add("@ProductId", request.ProductId); parameters.Add("@ProductName", request.ProductName); parameters.Add("@Price", request.Price); parameters.Add("@AvatarPath", request.AvatarPath); parameters.Add("@CategoryId", request.CategoryId); parameters.Add("@AquariumSizeId", request.AquariumSizeId); parameters.Add("@Status", request.Status); result = await SqlMapper.QueryFirstOrDefaultAsync <SaveProductRes>(cnn : connection, sql : "sp_SaveProduct", param : parameters, commandType : CommandType.StoredProcedure); return(result); } catch (Exception) { return(result); } }
public async Task <Response> Save(SaveProductReq request) { var result = new Response() { Id = 0, Message = "Something went wrong, please contact administrator." }; try { DynamicParameters parameters = new DynamicParameters(); parameters.Add("@Id", request.Id); parameters.Add("@ProductName", request.Productname); parameters.Add("@CategoryId", request.CategoryId); parameters.Add("@BrandId", request.BrandId); parameters.Add("@Price", request.Price); parameters.Add("@Description", request.Description); parameters.Add("@StatusProduct", request.StatusProduct); parameters.Add("@DateofSale", request.DateofSale); parameters.Add("@UserId", request.UserId); parameters.Add("@Image", request.Image); parameters.Add("@Images", request.Images); result = await SqlMapper.QueryFirstOrDefaultAsync <Response>(cnn : connection, sql : "sp_SaveProduct", param : parameters, commandType : CommandType.StoredProcedure); return(result); } catch (Exception ex) { result.Message = ex.Message; return(result); } }
public async Task <SaveProductRes> Save(SaveProductReq request) { return(await productRepository.Save(request)); }
public SaveProductRes SaveProduct([FromBody] SaveProductReq request) { return(productService.SaveProductRes(request)); }
public SaveProductRes SaveProductRes(SaveProductReq saveProductReq) { return(productRepository.SaveProduct(saveProductReq)); }
public async Task <OkObjectResult> Save(SaveProductReq request) { var result = await productService.Save(request); return(Ok(result)); }