public bool Add(IList <string> addArgs) { try { IPet pet = this.pets.FirstOrDefault(n => n.Name == addArgs[0]); IClinic clinic = this.clinics.FirstOrDefault(n => n.Name == addArgs[1]); if (pet == null || clinic == null) { throw new InvalidOperationException("Invalid Operation!"); } foreach (var room in clinic.AddEnumerator()) { if (!room.IsBusy) { // Room is empty => add pet to room room.IsBusy = true; room.Pet = pet; return(true); } } } catch (InvalidOperationException e) { Utilities.Output.AddReportLine(e.Message); } // There is not place in this clinic return(false); }
public bool Release(string clinicName) { try { IClinic clinic = this.clinics.FirstOrDefault(n => n.Name == clinicName); if (clinic == null) { // Clinic not found throw new InvalidOperationException("Invalid Operation!"); } foreach (var room in clinic.ReleaseEnumerator()) { if (room.IsBusy) { // Room is busy => release animal room.IsBusy = false; room.Pet = null; return(true); } } } catch (InvalidOperationException e) { Utilities.Output.AddReportLine(e.Message); } return(false); }
public bool HasEmptyRooms(string clinicName) { try { IClinic clinic = this.clinics.FirstOrDefault(n => n.Name == clinicName); if (clinic == null) { // Clinic not found throw new InvalidOperationException("Invalid Operation!"); } foreach (var room in clinic.Rooms) { if (!room.IsBusy) { // Empty room is found return(true); } } } catch (InvalidOperationException e) { Utilities.Output.AddReportLine(e.Message); } return(false); }
public bool AddPetToClinic(string petName, string clinicName) { IPet pet = GetConcretePet(petName); IClinic clinic = GetConcreteClinic(clinicName); return(clinic.AddPet(pet)); }
private void doSelectDoctor(ChatInfo chatInfo, CommandInfo commandInfo) { IClinic clinic = chatInfo.Info.Clinic; if (clinic == null) { return; } ISpeciality speciality = chatInfo.Info.Speciality; if (speciality == null) { return; } IDoctor doctor; switch (commandInfo.Command) { case Commands.Back: commandInfo.Command = Commands.RefreshByCommand; chatInfo.ChatLevel = Level.SelectClinic; doStep(chatInfo, commandInfo); return; case Commands.Refresh: commandInfo.Command = Commands.RefreshByCommand; chatInfo.ChatLevel = Level.SelectSpec; doStep(chatInfo, commandInfo); return; case Commands.RefreshByCommand: doctor = chatInfo.Info.Doctor; break; case Commands.SelectItem: { var doctors = _repository.GetDoctors(clinic, speciality); if (commandInfo.Index > doctors.Count || commandInfo.Index <= 0) { sendErrorCommand(chatInfo.ChatId, commandInfo.OriginalCommand); return; } doctor = doctors[commandInfo.Index - 1]; break; } default: sendErrorCommand(chatInfo.ChatId, commandInfo.OriginalCommand); return; } _botClient.SendChatActionAsync(chatInfo.ChatId, Telegram.Bot.Types.Enums.ChatAction.Typing); _botClient.SendTextMessageAsync(chatInfo.ChatId, getTicketsMessage(clinic, doctor)); chatInfo.ChatLevel = Level.SelectTicket; chatInfo.SetDoctor(doctor); }
public IList <ISpeciality> GetSpecialities(IClinic clinic) { if (!_specialities.ContainsKey(clinic)) { loadSpecialities(clinic); } return(_specialities[clinic]); }
public bool Release(string[] inputArgs) { IClinic clinic = clinics.FirstOrDefault(x => x.Name == inputArgs[0]); if (clinic is null) { throw new InvalidOperationException("Not existing clinic!"); } return(clinic.Release()); }
private IClinic GetClinic(string nameOfClinic) { IClinic clinic = clinics.FirstOrDefault(x => x.Name == nameOfClinic); if (clinic is null) { throw new InvalidOperationException("Not existing clinic!"); } return(clinic); }
public void Print(string[] inputArgs) { IClinic clinic = GetClinic(inputArgs[0]); if (inputArgs.Length == 1) { clinic.Print(); return; } int room = int.Parse(inputArgs[1]); clinic.Print(room); }
public bool AddPetToClinic(string[] inputArgs) { string petName = inputArgs[0]; string clinicName = inputArgs[1]; IClinic clinic = GetClinic(clinicName); IPet pet = petPool.FirstOrDefault(x => x.Name == petName); if (pet is null) { throw new InvalidOperationException("Not existing animal!"); } petPool.Remove(pet); return(clinic.Add(pet)); }
private string getSpecialitiesMessage(IClinic clinic) { var stringBuilder = new StringBuilder(); var specialities = _repository.GetSpecialities(clinic); for (int i = 0; i < specialities.Count; ++i) { stringBuilder.AppendLine($"{i + 1}. {specialities[i].DoctorName}"); } stringBuilder.AppendLine(string.Empty); stringBuilder.AppendLine("0. Вернуться назад"); stringBuilder.AppendLine("Наберите номер специализации"); return(stringBuilder.ToString()); }
private string getTicketsMessage(IClinic clinic, IDoctor doctor) { var stringBuilder = new StringBuilder(); var tickets = _repository.GetTickets(clinic, doctor); for (int i = 0; i < tickets.Count; ++i) { stringBuilder.AppendLine($"{tickets[i].Time}"); } stringBuilder.AppendLine(string.Empty); stringBuilder.AppendLine("0. Вернуться назад"); stringBuilder.AppendLine("00. Обновить"); stringBuilder.AppendLine("Наберите + чтобы начать следить"); return(stringBuilder.ToString()); }
private string getDoctorsMessage(IClinic clinic, ISpeciality speciality) { var stringBuilder = new StringBuilder(); var doctors = _repository.GetDoctors(clinic, speciality); for (int i = 0; i < doctors.Count; ++i) { stringBuilder.AppendLine($"{i + 1}. {doctors[i].DoctorName} номерков {doctors[i].FreeTickets}"); } stringBuilder.AppendLine(string.Empty); stringBuilder.AppendLine("0. Вернуться назад"); stringBuilder.AppendLine("00. Обновить"); stringBuilder.AppendLine("Наберите номер доктора"); return(stringBuilder.ToString()); }
public void Create(string[] args) { var name = args[1]; var ageOrCapacity = int.Parse(args[2]); if (args.Length == 4) { var kind = args[3]; IPet pet = petFactory.CreatePet(name, ageOrCapacity, kind); this.pets.Add(pet); } else { IClinic clinic = clinicFactory.CreateClinic(name, ageOrCapacity); this.clinics.Add(clinic); } }
public void Print(string clinicName, int room) { IClinic clinic = this.clinics.FirstOrDefault(n => n.Name == clinicName); if (clinic == null) { // Clinic not found throw new InvalidOperationException("Invalid Operation!"); } if (room < 1 || room > clinic.RoomsCount) { // Invalid room index throw new InvalidOperationException("Invalid Operation!"); } Output.AddReportLine(clinic.Rooms[room - 1].IsBusy ? clinic.Rooms[room - 1].Pet.ToString() : "Room empty"); }
public void Print(string clinicName) { try { IClinic clinic = this.clinics.FirstOrDefault(n => n.Name == clinicName); if (clinic == null) { // Clinic not found throw new InvalidOperationException("Invalid Operation!"); } foreach (var room in clinic.Rooms) { Output.AddReportLine(room.IsBusy ? room.Pet.ToString() : "Room empty"); } } catch (InvalidOperationException e) { Utilities.Output.AddReportLine(e.Message); } }
public string PrintRoom(string clinicName, int room) { IClinic clinic = this.GetConcreteClinic(clinicName); return(clinic.GetRoomState(room)); }
public ClinicSpec(IClinic clinic, ISpeciality spec) { Clinic = clinic; Spec = spec; }
public void SetClinic(IClinic clinic) { Info.Clinic = clinic; Info.Speciality = null; Info.Doctor = null; }
public bool RealesePet(string clinicName) { IClinic clinic = this.GetConcreteClinic(clinicName); return(clinic.ReleasePet()); }
private IReadOnlyCollection <ITicket> loadTickets(IClinic clinic, IDoctor doctor) { string content = _ticketCollectionDataResolver.RequestProcess(clinic.Id, doctor.Id); return(_ticketCollectionParser.Parse(content)); }
public bool HasEmptyRooms(string clinicName) { IClinic clinic = this.GetConcreteClinic(clinicName); return(clinic.HasEmptyRooms()); }
public IList <ITicket> GetTickets(IClinic clinic, IDoctor doctor) { return(loadTickets(clinic, doctor).ToList()); }
private void loadSpecialities(IClinic clinic) { string content = _specialityCollectionDataResolver.RequestProcess(clinic.Id); _specialities[clinic] = _specialityCollectionParser.ParseSpecialities(content); }
public HomeController(ILogger <HomeController> logger, IClinic clinicRepo, AppDbContext context) { this.context = context; this.clinicRepo = clinicRepo; _logger = logger; }
public string PrintAll(string clinicName) { IClinic clinic = this.GetConcreteClinic(clinicName); return(clinic.GetAllRoomState()); }
public PetService(IClinic clinic) { _clinic = clinic; }
public IClinic GetConcreteClinic(string clinicName) { IClinic clinic = this.clinics.FirstOrDefault(x => x.Name == clinicName); return(clinic); }
public IList <IDoctor> GetDoctors(IClinic clinic, ISpeciality speciality) { var key = new ClinicSpec(clinic, speciality); return(loadDoctors(key)); }