I work on angular 7 I face issue I can't call web API return Boolean from angular 7
so how call web API on angular 7 return true or false
[HttpGet]
[Route("CompareExcel/SelectedOptions")]
public IActionResult CompareExcel( int SelectedOptions)
{
var DisplayFileName = Request.Form.Files[0];
string fileName = DisplayFileName.FileName.Replace(".xlsx", "-") + Guid.NewGuid().ToString() + ".xlsx";
string Month = DateTime.Now.Month.ToString();
string DirectoryCreate = Path.Combine(myValue1, Month);// myValue1 + "\\" + Month + "\\" + fileName;
CExcel ex = new CExcel();
string error = "";
int rowCount = 0;
var selectedFile = "";
var filedata = ContentDispositionHeaderValue.Parse(Request.Form.Files[0].ContentDisposition).FileName.Trim('"');
var dbPath = Path.Combine(DirectoryCreate, fileName);
if (SelectedOptions == 1)
{
selectedFile = "Gen.xlsx";
}
else if(SelectedOptions == 2)
{
selectedFile = "DeliveryGeneration_Input.xlsx";
}
var InputfilePath = System.IO.Path.Combine(GetFilesDownload, selectedFile);
using (var stream = new FileStream(dbPath, FileMode.Create))
{
Request.Form.Files[0].CopyTo(stream);
stream.Flush();
stream.Close();
}
GC.Collect();
bool areIdentical = ex.CompareExcel(dbPath, InputfilePath, out rowCount, out error);
if(areIdentical==true)
{
return Ok(true);
}
else
{
return Ok(false);
}
}
link used to call web API from angular
http://localhost:61265/api/DeliverySys/CompareExcel/SelectedOptions?=1
when call function above it return only Boolean true or false
if compare excel identical then return true
if compare excel Not identical then return false
so on angular service.ts
//what I write
component Type script ts
what I write
html component
what I write
updated post
on service ts i do as below :
CompareExcel(SelectedOptions)
{
this.http.get('http://localhost:61265/api/DeliverySys/CompareExcel/SelectedOptions?=' + SelectedOptions).subscribe(result => {
console.log(result);
});
}
on component ts
i call it as
this._dataService.CompareExcel(this.selectedoptions.toString())
so are this correct
on component html
what i write