public ActionResult GetSpecificIcu(string id) { //return _repository.GetIcuById(id); Models.Icu icu = _repository.GetIcuById(id); if (icu == null) { return(NotFound($"ICU with ID {id} is not Present")); } return(Ok(icu)); }
public ActionResult UpdateIcu(string id, Models.Icu icu) { var IcuModelFromRepository = _repository.GetIcuById(id); if (id != icu.Id) { return(BadRequest("Enter Valid Details")); } if (IcuModelFromRepository == null) { return(NotFound()); } IcuModelFromRepository.BedCount = icu.BedCount; IcuModelFromRepository.LayoutId = icu.LayoutId; _repository.UpdateIcu(icu); _repository.SaveChanges(); return(Ok()); }
public ActionResult AddIcu(Models.Icu icu) { /* if(!_repository.CheckLayoutId(icu.LayoutId)) * { * return new ObjectResult("Not Registered Layout"); * }*/ Validations_Icu validations = new Validations_Icu(); bool Response = validations.ValidateIcu(icu); if (Response == false) { return(BadRequest("Please Enter Valid Details")); } try { _repository.AddNewIcu(icu); _repository.SaveChanges(); return(Ok("Icu Added Successfully")); } catch (SQLiteException exception) { return(BadRequest(exception.Message)); } }