public async Task <IActionResult> Delete(int id) { var result = await _hospitalService.Delete(id); if (result.Success) { return(Ok(result.Message)); } return(BadRequest(result.Message)); }
public IActionResult Delete(int id) { Hospital deletedObject = _hospitalService.GetById(id).Data; var result = _hospitalService.Delete(deletedObject); if (result.Success) { return(Ok(result)); } return(BadRequest(result)); }
public ActionResult Edit(Models.Hospital.AddViewModel model) { if (!ModelState.IsValid) { //select list model.CitySelectList = GetCitySelectList(); return(View(model)); } //select list model.CitySelectList = GetCitySelectList(); try { var hospital = _hospitalService.GetById(model.Id); if (hospital == null) { return(View("_ErrorNotExist")); } hospital.Name = model.Name; hospital.Phone = model.Phone; hospital.Address = model.Address; hospital.CityCode = model.CityCode; if (model.SubmitType == "Edit") { _hospitalService.Update(hospital); } if (model.SubmitType == "Delete") { _hospitalService.Delete(hospital.Id, SessionHelper.CurrentUser.Id); } return(RedirectToAction(nameof(HospitalController.List))); } catch { ViewBag.ErrorMessage = "Not Operation."; return(View(model)); } }
public ActionResult Delete(int id, Hospital hospital) { _hospitalService.Delete(hospital); _logger.LogInformation("The hospital was deleted!"); return(RedirectToAction(nameof(Index))); }