i have a problem in adding entity to database in .net core.all of my code execute with no error but any record inserts in database this is my adding service below
public async Task<int> AddHpl(IFormFile ClinicImgUp, AddHealthPlaceViewModel addHealthPlaceViewModel)
{
TableHpl tableHpl = new TableHpl
{
TabloTitle = addHealthPlaceViewModel.TabloTitle,
Address = addHealthPlaceViewModel.Address,
Services = addHealthPlaceViewModel.Services,
Others = addHealthPlaceViewModel.Others,
Personels = addHealthPlaceViewModel.Personels,
CityCode = addHealthPlaceViewModel.CityCode,
Recid = addHealthPlaceViewModel.Recid,
Telegram = addHealthPlaceViewModel.Telegram,
Email = addHealthPlaceViewModel.Email,
Website = addHealthPlaceViewModel.Website,
Instagram = addHealthPlaceViewModel.Instagram,
PlaceCode = addHealthPlaceViewModel.PlaceCode,
TableHplphones = new List<TableHplphone>
{
new TableHplphone
{
Mobile = addHealthPlaceViewModel.Hplphones[0].Mobile,
OfficePhone = addHealthPlaceViewModel.Hplphones[0].OfficePhone
},
new TableHplphone
{
Mobile = addHealthPlaceViewModel.Hplphones[1].Mobile,
OfficePhone = addHealthPlaceViewModel.Hplphones[1].OfficePhone
}
}
};
if (ClinicImgUp != null && ClinicImgUp.IsImage())
{
tableHpl.OfficePic = NameGenerator.GenerateUniqCode() + Path.GetExtension(ClinicImgUp.FileName);
string imagePath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot/img", tableHpl.OfficePic);
await using var stream = new FileStream(imagePath, FileMode.Create);
ImageResizer.ResizeImage(ClinicImgUp, stream);
}
await _context.TableHpls.AddAsync(tableHpl);
return tableHpl.Hplid;
}
any help will be highly appreciated