Exemplo n.º 1
0
        public JsonResult DeleteHospital(string id)
        {
            bool result = _hospitalservice.DeleteHospital(Convert.ToInt32(id));

            if (result)
            {
                return(Json("Successfully deleted Record !"));
            }
            else
            {
                TempData["Delete"] = string.Format("Error Coming While Deleting Data");
                return(Json("Error Coming While Deleting Data"));
            }
        }
        //1/10/19 aakansha

        // Post: Hospital/Delete/5
        public virtual IActionResult Delete(int id)
        {
            ResponceModel responceModel = new ResponceModel();

            try
            {
                var hospital = _hospitalServices.GetHospitalById(id);
                if (hospital == null)
                {
                    //No product found with the specified id
                    return(RedirectToAction("List"));
                }
                if (hospital != null)
                {
                    var count = _treatmentRecordService.GetPatientInfoByHospitalId(id).Count();
                    if (count == 0)
                    {
                        _hospitalServices.DeleteHospital(hospital);
                        responceModel.Success = true;
                        responceModel.Message = "Deleted.";
                        AddNotification(NotificationMessage.TitleSuccess, NotificationMessage.msgDeleteHospital, NotificationMessage.TypeSuccess);
                        return(Json(responceModel));
                    }
                    else
                    {
                    }
                }
                responceModel.Success = false;
                responceModel.Message = "NotDeleted.";
                AddNotification(NotificationMessage.TitleError, NotificationMessage.ErrormsgDeleteHospital, NotificationMessage.TypeError);
                return(Json(responceModel));
            }
            catch (Exception e)
            {
                responceModel.Success = false;
                responceModel.Message = "NotDeleted.";
                AddNotification(NotificationMessage.TitleError, NotificationMessage.ErrormsgDeleteHospital, NotificationMessage.TypeError);
                return(Json(responceModel));
            }
        }