public ActionResult Add(Models.Hospital.AddViewModel model) { if (!ModelState.IsValid) { //select list model.CitySelectList = GetCitySelectList(); return(View(model)); } //select list model.CitySelectList = GetCitySelectList(); HealthyDuty.Data.Entity.Hospital hospital = new HealthyDuty.Data.Entity.Hospital(); hospital.Name = model.Name; hospital.Phone = model.Phone; hospital.Address = model.Address; hospital.CityCode = model.CityCode; hospital.IsDeleted = false; try { _hospitalService.Add(hospital); return(RedirectToAction(nameof(HospitalController.List))); } catch { ViewBag.ErrorMessage = "Not Saved."; return(View(model)); } }
public IActionResult Add(Hospital hospital) { var result = _hospitalService.Add(hospital); if (result.Success) { return(Ok(result)); } return(BadRequest(result)); }
public ActionResult Create(Hospital hospital) { //Hospital hospital = new Hospital(); //hospital.city = model.city; //hospital.cityID = model.cityID; //hospital.currentCapacity = model.currentCapacity; //hospital.hospitalID = model.hospitalID; //hospital.hospitalName = model.hospitalName; //hospital.maxCapacity = model.maxCapacity; //hospital.cityName = model.cityName; if (hospital != null) { if (!string.IsNullOrEmpty(hospital.hospitalName) || !string.IsNullOrWhiteSpace(hospital.hospitalName)) { _hospitalService.Add(hospital); _logger.LogInformation("New City was added!"); } } return(RedirectToAction(nameof(Index))); }