Пример #1
0
        /// <summary>
        /// Creates an UserViewModel given an User object.
        /// </summary>
        /// <param name="user">User object to be used as source of values.</param>
        /// <param name="practice"> </param>
        /// <param name="medicalEntity">medical entity, if the user is a doctor. If medical entity is null, medical entity won't be added to the view-model even if the user is a doctor</param>
        /// <param name="medicalSpecialty">medical specialty, if the user is a doctor. If medical specialty is null, medical specialty won't be added to the view-model even if the user is a doctor</param>
        /// <returns>A new UserViewModel with informations copied from the User object.</returns>
        public static UserViewModel GetViewModel(
            [NotNull] User user, [NotNull] Practice practice, SYS_MedicalEntity medicalEntity = null, SYS_MedicalSpecialty medicalSpecialty = null)
        {
            if (user == null) throw new ArgumentNullException("user");
            if (practice == null) throw new ArgumentNullException("practice");

            var address = user.Person.Addresses.SingleOrDefault();

            var viewModel = new UserViewModel();

            FillUserViewModel(user, practice, viewModel);

            viewModel.Address = address == null
                                    ? new AddressViewModel()
                                    : new AddressViewModel
                                          {
                                              CEP = address.CEP,
                                              City = address.City,
                                              Complement = address.Complement,
                                              Neighborhood = address.Neighborhood,
                                              StateProvince = address.StateProvince,
                                              Street = address.Street
                                          };

            var userDoctor = user.Doctor;
            if (userDoctor != null)
                FillDoctorViewModel(user, medicalEntity, medicalSpecialty, viewModel, userDoctor);

            return viewModel;
        }
 /// <summary>
 /// Create a new SYS_MedicalSpecialty object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="name">Initial value of the Name property.</param>
 public static SYS_MedicalSpecialty CreateSYS_MedicalSpecialty(global::System.Int32 id, global::System.String name)
 {
     SYS_MedicalSpecialty sYS_MedicalSpecialty = new SYS_MedicalSpecialty();
     sYS_MedicalSpecialty.Id = id;
     sYS_MedicalSpecialty.Name = name;
     return sYS_MedicalSpecialty;
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the SYS_MedicalSpecialty EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToSYS_MedicalSpecialty(SYS_MedicalSpecialty sYS_MedicalSpecialty)
 {
     base.AddObject("SYS_MedicalSpecialty", sYS_MedicalSpecialty);
 }
Пример #4
0
 internal static void FillDoctorViewModel(User user, SYS_MedicalEntity medicalEntity, SYS_MedicalSpecialty medicalSpecialty, UserViewModel viewModel, Doctor doctor)
 {
     viewModel.MedicCRM = doctor.CRM;
     viewModel.MedicalSpecialtyId = medicalSpecialty != null ? medicalSpecialty.Id : (int?)null;
     viewModel.MedicalSpecialtyName = medicalSpecialty != null ? medicalSpecialty.Name : null;
     viewModel.MedicalEntityId = medicalEntity != null ? medicalEntity.Id : (int?)null;
     viewModel.MedicalEntityName = medicalEntity != null ? medicalEntity.Name : null;
     viewModel.MedicalEntityJurisdiction = (int)(TypeEstadoBrasileiro)Enum.Parse(
         typeof(TypeEstadoBrasileiro),
         user.Doctor.MedicalEntityJurisdiction);
 }