public async Task <IActionResult> updateMerchantCatalog([FromBody] UpdateMerchantCatalogDto UpdateMerchantCatalogDto) { try { int checkvalue = await _MerchantCatalogService.CheckMerchantCatalogForupdate(UpdateMerchantCatalogDto.MerchantCatalogId, UpdateMerchantCatalogDto.MerchantID, UpdateMerchantCatalogDto.CategoryID, UpdateMerchantCatalogDto.Subcategory, UpdateMerchantCatalogDto.Brand, UpdateMerchantCatalogDto.Product); if (checkvalue == 0) { await _MerchantCatalogService.UpdateMerchantCatalog(UpdateMerchantCatalogDto); return(Ok(new GenericResultDto <string> { Result = "Merchant Catalog updated successfully" })); } return(BadRequest(new GenericResultDto <string> { Result = "Cannot have a duplicate row with the same Category, Subcategory, Brand, Product for a Merchant" })); } catch (Exception err) { return(BadRequest(new GenericResultDto <string> { Result = err.Message })); } }
public async Task UpdateMerchantCatalog(UpdateMerchantCatalogDto UpdateMerchantCatalogDto) { var isvalid = Repository.SingleOrDefault(x => x.Id == UpdateMerchantCatalogDto.MerchantCatalogId); if (UpdateMerchantCatalogDto.CategoryID > 0) { isvalid.CategoryID = UpdateMerchantCatalogDto.CategoryID; } if (!string.IsNullOrEmpty(UpdateMerchantCatalogDto.Subcategory)) { isvalid.Subcategory = UpdateMerchantCatalogDto.Subcategory; } if (!string.IsNullOrEmpty(UpdateMerchantCatalogDto.Brand)) { isvalid.Brand = UpdateMerchantCatalogDto.Brand; } if (!string.IsNullOrEmpty(UpdateMerchantCatalogDto.Product)) { isvalid.Product = UpdateMerchantCatalogDto.Product; } await Repository.UpdateAsync(isvalid); }