public async Task <ActionResult> Update([FromBody] UpdateCategory data, string productFor, string productType) { try { var checkData = MH.CheckForDatas("ProductFor", productFor, "ProductType", productType, "ProductDB", "Category"); if (checkData != null) { var objectId = BsonSerializer.Deserialize <Category>(checkData).Id; var filter = Builders <BsonDocument> .Filter.Eq("_id", objectId); if (data.ProductFor != null) { var objectName = data.ProductFor + "-" + BsonSerializer.Deserialize <Category>(MH.CheckForDatas("_id", objectId, null, null, "ProductDB", "Category")).ProductType; await MH.UpdateCategoryDetails(BsonSerializer.Deserialize <Category>(checkData).Id, productFor, productType, data.ProductFor, "ProductFor", objectName + ".jpg"); } if (data.ProductType != null) { var objectName = BsonSerializer.Deserialize <Category>(MH.CheckForDatas("_id", objectId, null, null, "ProductDB", "Category")).ProductFor + "-" + data.ProductType; await MH.UpdateCategoryDetails(BsonSerializer.Deserialize <Category>(checkData).Id, productFor, productType, data.ProductType, "ProductType", objectName + ".jpg"); } if (data.Description != null) { var update = await MH.UpdateSingleObject(filter, "ProductDB", "Category", Builders <BsonDocument> .Update.Set("Description", data.Description)); } return(Ok(new ResponseData { Code = "200", Message = "Updated", Data = null })); } else { return(BadRequest(new ResponseData { Code = "404", Message = "Category not found", Data = null })); } } catch (Exception ex) { LoggerDataAccess.CreateLog("CategoryController", "Update", ex.Message); return(BadRequest(new ResponseData { Code = "400", Message = "Failed", Data = ex.Message })); } }