예제 #1
0
        public async Task <ActionResult> UpdatePacient(GetPacientDto pacientDto)
        {
            var userName = User.GetUserName();

            var pacient = await _pacientRepository.GetPacientByUsername(userName);

            pacient.Pacient.FirstName  = pacientDto.FirstName;
            pacient.Pacient.SecondName = pacientDto.SecondName;
            pacient.Pacient.User.Email = pacientDto.Email;
            pacient.Pacient.Email      = pacientDto.Email;

            if (pacient.Pacient.PacientContact == null)
            {
                pacient.Pacient.PacientContact = new Entities.PacientContact();
            }

            pacient.Pacient.PacientContact.Street       = pacientDto.PacientContact.Street;
            pacient.Pacient.PacientContact.StreetNumber = pacientDto.PacientContact.StreetNumber;
            pacient.Pacient.PacientContact.FirstPhone   = pacientDto.PacientContact.FirstPhone;
            pacient.Pacient.PacientContact.SecondPhone  = pacientDto.PacientContact.SecondPhone;
            pacient.Pacient.PacientContact.CityId       = pacientDto.PacientContact.CityId;

            _pacientRepository.Update(pacient.Pacient);

            if (await _pacientRepository.SaveAllAsync())
            {
                return(NoContent());
            }

            return(BadRequest("Upss...ceva nu a mers!"));
        }
        public async Task <ActionResult> MakeAnAppoinment(MakeAnAppoinmentDto makeAnAppoinmentDto)
        {
            var userPacient = await _pacientRepository.GetPacientByUsername(User.GetUserName());

            if (makeAnAppoinmentDto == null ||
                makeAnAppoinmentDto.DoctorId == 0 ||
                makeAnAppoinmentDto.DayUnixTime == 0 ||
                makeAnAppoinmentDto.FromTimeSpan == 0 || makeAnAppoinmentDto.ToTimeSpan == 0 || userPacient.Pacient == null)
            {
                return(BadRequest("Parametrii invalizi!"));
            }

            if (await _appoinmentsRepository.AddAppoinmentAsync(makeAnAppoinmentDto, userPacient.Pacient.Id))
            {
                return(Ok());
            }

            return(BadRequest("Upps..ceva nu a mers!"));
        }