public async Task <IActionResult> IndexPost([FromForm] ScanCenterProductRequestModel productRequestModel) { if (productRequestModel == null) { return(new BadRequestObjectResult(new { message = "Bad Request" })); } var img = new List <string>(); foreach (IFormFile file in productRequestModel.Files) { var path = await _fileManager.Save($"/UserFiles/ScanCenter/Admin/product/", _hostEnvironment.WebRootPath, file); img.Add(path); } productRequestModel.ScanCenterProfileId = 0; productRequestModel.IsAdminProduct = true; productRequestModel.Images = JsonConvert.SerializeObject(img.ToArray()); await _scanCenterProductQuery.CreateProduct(productRequestModel); return(Ok(new { success = "success" })); }
public async Task <IActionResult> IndexPost(int id, [FromForm] ScanCenterProductRequestModel productRequestModel) { if (id == 0) { return(new BadRequestObjectResult(new { message = "Bad Request" })); } if (!await CheckAuth(id)) { return(new BadRequestObjectResult(new { message = "Bad Request" })); } ViewData["Id"] = id; var img = new List <string>(); foreach (IFormFile file in productRequestModel.Files) { var path = await _fileManager.Save($"/UserFiles/ScanCenter/{id}/product/", _hostEnvironment.WebRootPath, file); img.Add(path); } //if (productRequestModel.Brand == null) // productRequestModel.Brand = string.Empty; //if (productRequestModel.Category == null) // productRequestModel.Category = string.Empty; productRequestModel.ScanCenterProfileId = id; productRequestModel.Images = JsonConvert.SerializeObject(img.ToArray()); int pdtId = await _scanCenterProductQuery.CreateProduct(productRequestModel); return(Ok()); }