Example #1
0
 public void Update(PatientAccount entity)
 {
     try
     {
         var memento = entity.GetPatientMemento();
         var patient = _context.Patients.Find(memento.Jmbg);
         if (patient is null)
         {
             throw new NotFoundException("Patient account with jmbg " + memento.Jmbg + " does not exist.");
         }
         if (patient.IsGuest)
         {
             throw new NotFoundException("Patient account with jmbg " + memento.Jmbg + " does not exist.");
         }
         patient.IsActive  = memento.IsActivated;
         patient.IsBlocked = memento.IsBlocked;
         patient.ImageName = memento.ImageName;
         _context.Update(patient);
         _context.SaveChanges();
     }
     catch (UserServiceException)
     {
         throw;
     }
     catch (DbUpdateException e)
     {
         throw new ValidationException(e.Message);
     }
     catch (Exception e)
     {
         throw new DataStorageException(e.Message);
     }
 }
Example #2
0
        public static MaliciousPatientDTO ToMaliciousPatientDTO(this PatientAccount patient)
        {
            var memento = patient.GetPatientMemento();

            return(new MaliciousPatientDTO()
            {
                Name = memento.Name,
                Surname = memento.Surname,
                Email = memento.Email,
                Jmbg = memento.Jmbg,
                HomeAddress = memento.HomeAddress,
                CityName = memento.City.Name,
                CountryName = memento.City.Country.Name,
                Phone = memento.Phone,
                IsBlocked = memento.IsBlocked,
                NumberOfMaliciousActions = memento.MaliciousActions.Count(),
                ImageName = memento.ImageName
            });
        }
Example #3
0
        public static PatientDTO ToPatientDTO(this PatientAccount patient)
        {
            var memento = patient.GetPatientMemento();

            return(new PatientDTO()
            {
                Name = memento.Name,
                Surname = memento.Surname,
                Email = memento.Email,
                Jmbg = memento.Jmbg,
                Phone = memento.Phone,
                DateOfBirth = memento.DateOfBirth,
                CityId = memento.City.Id,
                CityName = memento.City.Name,
                CountryId = memento.City.Country.Id,
                CountryName = memento.City.Country.Name,
                HomeAddress = memento.HomeAddress,
                ImageName = memento.ImageName,
                Gender = memento.Gender.ToString()
            });
        }
Example #4
0
        internal static Patient ToBackendPatient(this PatientAccount patient)
        {
            var memento = patient.GetPatientMemento();

            return(new Patient()
            {
                Jmbg = memento.Jmbg,
                DateOfBirth = memento.DateOfBirth,
                CityZipCode = memento.City.Id,
                DateOfRegistration = DateTime.Now,
                Email = memento.Email,
                Gender = memento.Gender.ToBackendGender(),
                HomeAddress = memento.HomeAddress,
                ImageName = memento.ImageName,
                IsActive = memento.IsActivated,
                IsBlocked = memento.IsBlocked,
                Name = memento.Name,
                IsGuest = false,
                Password = memento.Password,
                Phone = memento.Phone,
                Surname = memento.Surname,
                Username = memento.Email
            });
        }