コード例 #1
0
        public async Task <IActionResult> CreateScheduling()
        {
            var schedulingDataModel = new SchedulingDataModel()
            {
                Dentists = await _dentistService.GetAll()
            };

            return(PartialView("_CreateScheduling", schedulingDataModel));
        }
コード例 #2
0
        public async Task <IActionResult> Create(SchedulingDataModel request)
        {
            await _schedulingService.Create(request);

            if (ValidOperation() is false)
            {
                request.Dentists = await _dentistService.GetAll();

                return(PartialView("_CreateScheduling", request));
            }

            var url = Url.Action("Index", "Scheduling");

            return(Json(new { success = true, url, messageText = "Agendamento Cadastrado com Sucesso!" }));
        }
コード例 #3
0
        public async Task <IActionResult> Edit(Guid id, SchedulingDataModel request)
        {
            request.Id = id;

            await _schedulingService.Update(request);

            if (ValidOperation() is false)
            {
                request.Dentists = await _dentistService.GetAll();

                return(PartialView("_EditScheduling", request));
            }

            var url = Url.Action("Index", "Scheduling");

            return(Json(new { success = true, url }));
        }
コード例 #4
0
        public async Task <SchedulingDataModel> Get(Guid id)
        {
            SchedulingDataModel schedulingModel = null;

            var scheduling = await _schedulingRepository.GetAsync(id);

            if (scheduling is null)
            {
                Notify("Dados do Agendamento não encontrado.");
            }
            else
            {
                schedulingModel = new SchedulingDataModel()
                {
                    Id      = scheduling.Id,
                    Patient = new PatientDataModel()
                    {
                        Cpf        = scheduling.Patient.Cpf,
                        Name       = scheduling.Patient.Name,
                        BirthDate  = scheduling.Patient.BirthDate,
                        Street     = scheduling.Patient.Street,
                        Number     = scheduling.Patient.Number,
                        Complement = scheduling.Patient.Complement,
                        District   = scheduling.Patient.District,
                        State      = scheduling.Patient.State,
                        City       = scheduling.Patient.City,
                    },
                    PatientId = scheduling.Patient.Id,
                    Dentist   = new DentistDataModel()
                    {
                        Id   = scheduling.Dentist.Id,
                        Name = scheduling.Dentist.Name
                    },
                    DentistId     = scheduling.Dentist.Id,
                    TypeExpertise = scheduling.Dentist.Expertise,
                    DateTime      = scheduling.Datetime,
                    Type          = scheduling.Type,
                    Obs           = scheduling.Obs,
                    Dentists      = await _dentistService.GetAll()
                };
            }

            return(schedulingModel);
        }
コード例 #5
0
        public async Task Create(SchedulingDataModel request)
        {
            var dentist = await _dentistService.Get(request.DentistId);

            if (dentist is null)
            {
                Notify("Dentista não encontrado");
                return;
            }

            var patient = await _patientService.Get(request.Patient.Id);

            if (patient is null)
            {
                Notify("Paciente não encontrado");
                return;
            }

            if (request.DateTime == DateTime.MinValue)
            {
                Notify("Data inválida");
                return;
            }

            var scheduling = new Scheduling(request.DateTime, dentist.Id, request.Obs, patient.Id, request.Type, dentist.Expertise);

            if (scheduling.IsValid())
            {
                await _schedulingRepository.AddAsync(scheduling);
            }
            else
            {
                Notify(scheduling.ValidationResult);
                return;
            }

            if (await CommitAsync() is false)
            {
                Notify("Erro ao salvar dados.");
            }
        }