public StudentViewModel(Student student) : this()
        {
            if (student != null)
            {
                Id                   = student.Id;
                Username             = student.Username;
                FirstName            = student.FirstName;
                LastName             = student.LastName;
                Email                = student.Email;
                Gender               = student.Gender;
                DateOfBirth          = student.DateOfBirth;
                ExtracurricularPoint = 0;
                CertificateStatus    = new CertificateStatusViewModel(student.CertificateStatus);

                var extracurricularRepository         = IoCHelper.GetInstance <IRepository <Extracurricular> >();
                var extracurricularActivityRepository = IoCHelper.GetInstance <IRepository <ExtracurricularActivity> >();

                var extracurricularActivityIdArray = extracurricularRepository.GetAll()
                                                     .Where(x => x.StudentId == Id).Select(x => x.ExtracurricularActivityId).ToArray();

                Class = new ClassViewModel(student.Class);
                //ClassId = student.ClassId;
                //SpecialtyId = student.SpecialtyId;
                Specialty = new SpecialtyViewModel(student.Specialty);

                foreach (var extracurricularActivityId in extracurricularActivityIdArray)
                {
                    ExtracurricularPoint += extracurricularActivityRepository.GetAll().FirstOrDefault(x => x.Id == extracurricularActivityId).Point;
                }
                // Lấy điểm của từng
                //ExtracurricularPoint = student
                //Roles = user.UserInRoles != null ? user.UserInRoles.Select(y => new RoleViewModel(y.Role)).ToArray() : null;
            }
        }
Ejemplo n.º 2
0
 public int AddSpeciality(SpecialtyViewModel model)
 {
     try
     {
         using (UserContext db = new UserContext())
         {
             SpecialtyModel sp = new SpecialtyModel
             {
                 Id             = model.Id,
                 Prefix         = model.Prefix,
                 SpecialityName = model.SpecialityName,
                 FieldSpecialty = model.FieldSpecialty,
                 ValidUntil     = model.ValidUntil,
                 Quality        = model.Quality,
                 Pictures       = new List <PictureModel>(db.PicturesModels.Where(t => model.Templates.Contains(t.Id)))
             };
             sp = db.Specialties.Add(sp);
             db.SaveChanges();
             return(sp.Id);
         }
     }
     catch
     {
         return(0);
     }
 }
        private List <string> GetAllPropertyNameOfSpecialtyViewModel()
        {
            var specialtyViewModel = new SpecialtyViewModel();

            var type = specialtyViewModel.GetType();

            return(ReflectionUtilities.GetAllPropertyNamesOfType(type));
        }
Ejemplo n.º 4
0
 public ActionResult UpdateSpeciality(int Id)
 {
     using (UserContext db = new UserContext())
     {
         SpecialtyModel     sp = db.Specialties.Find(Id);
         SpecialtyViewModel vm = new SpecialtyViewModel(sp);
         return(PartialView(vm));
     }
 }
Ejemplo n.º 5
0
        internal ResourcesControl(PatientViewModel patient, SpecialtyViewModel specialty)
        {
            _patient   = patient;
            _specialty = specialty;

            var app = System.Windows.Application.Current as App;

            _mainWindow = app.MainWindow as MainWindow;

            InitializeComponent();
        }
        public async Task <IActionResult> CreateSpecialityAsync([FromBody] SpecialtyViewModel specialty)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(new ValidationError(ModelState)));
            }

            var newSpecialty = await _specialitiesService.CreateSpecialityAsync(_mapper.Map <SpecialtyDto>(specialty));

            return(CreatedAtRoute("GetSpeciality", new { specialtyId = newSpecialty.Id }, newSpecialty));
        }
Ejemplo n.º 7
0
        public async Task <IActionResult> Add(SpecialtyViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            await this
            .specialties
            .AddAsync(model.Name);

            TempData.AddSuccessMessage($"Specialty {model.Name} was added successfuly!");

            return(RedirectToAction(nameof(All)));
        }
        public async Task <IActionResult> UpdateSpecialityAsync(int specialtyId, [FromBody] SpecialtyViewModel specialty)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(new ValidationError(ModelState)));
            }

            var specialtyDto = _mapper.Map <SpecialtyDto>(specialty);

            specialtyDto.Id = specialtyId;

            await _specialitiesService.UpdateSpecialityAsync(specialtyDto);

            return(NoContent());
        }
Ejemplo n.º 9
0
        public ActionResult UpdateSpeciality(SpecialtyViewModel model)
        {
            using (UserContext db = new UserContext())
            {
                SpecialtyModel sp = db.Specialties.Find(model.Id);
                sp.SpecialityName = model.SpecialityName;
                sp.Prefix         = model.Prefix;
                sp.FieldSpecialty = model.FieldSpecialty;
                sp.ValidUntil     = model.ValidUntil;
                sp.Quality        = model.Quality;
                sp.Pictures.Clear();
                model.Templates.ToList().ForEach(tr => sp.Pictures.Add(db.PicturesModels.Find(tr)));

                db.Entry(sp).State = EntityState.Modified;
                db.SaveChanges();

                return(RedirectToAction("SpecialityPartialPage"));
            }
        }
Ejemplo n.º 10
0
        public ResponseViewModel UpdateSpecialty(SpecialtyViewModel model)
        {
            try
            {
                var specRepo = _uow.GetService <ISpecialtyRepository>();
                var spec     = _mapper.Map <Specialty>(model);

                specRepo.UpdateSpecialty(spec);
                _uow.Save();

                return(new ResponseViewModel {
                    Message = "Update successfull", Success = true
                });
            }
            catch (Exception e)
            {
                return(new ResponseViewModel {
                    Message = e.Message, Success = false
                });
            }
        }
Ejemplo n.º 11
0
        internal SpecialtyViewModel Get(int id)
        {
            var model = new SpecialtyViewModel();

            using (var conn = Connection)
            {
                var sql = $"select * from hlc_Specialty where ID={id};" +
                          "select d.id, d.FirstName, d.LastName, d.MobilePhone, d.Attitude, p.PracticeName, p.OfficePhone1 " +
                          "from hlc_DoctorSpecialty ds " +
                          "left join hlc_Doctor d on d.ID = ds.DoctorID " +
                          "left join hlc_Practice p on p.ID = d.PracticeID " +
                          $"where ds.SpecialtyID = {id} " +
                          "order by d.LastName, d.FirstName;";

                conn.Open();
                var multi = conn.QueryMultiple(sql);

                model.Specialty = multi.Read <Specialty>().FirstOrDefault();
                //model.Doctors = multi.Read<DoctorListViewModel>().ToList();
                model.Doctors = multi.Read <Doctor>().ToList();
            }
            return(model);
        }
Ejemplo n.º 12
0
        public Specialty(EntityContext _db)
        {
            InitializeComponent();

            DataContext = new SpecialtyViewModel(_db);
        }
Ejemplo n.º 13
0
        public ActionResult SpecialtyCreate([DataSourceRequest] DataSourceRequest request, SpecialtyViewModel specialty)
        {
            if (specialty != null && ModelState.IsValid)
            {
                var s = new Specialty
                {
                    Name = specialty.Name
                };

                _context.Specialty.Add(s);
                _context.SaveChanges();
            }

            return(Json(new[] { specialty }.ToDataSourceResult(request, ModelState)));
        }
Ejemplo n.º 14
0
        public ActionResult SpecialtyDelete([DataSourceRequest] DataSourceRequest request, SpecialtyViewModel specialty)
        {
            if (specialty != null && ModelState.IsValid)
            {
                var s = _context.Specialty.SingleOrDefault(ss => ss.Id == specialty.Id);
                if (s != null)
                {
                    _context.Specialty.Remove(s);
                    _context.SaveChanges();
                }
            }

            return(Json(new[] { specialty }.ToDataSourceResult(request, ModelState)));
        }
Ejemplo n.º 15
0
        public void Mock(UrlHelper urlHelper)
        {
            MemberName       = "Dermaine Peart";
            JobStatus        = 0;
            BusinessIsCalled = "Dentist";
            YearsInPractice  = 10;
            MonthStarted     = 6;
            YearStarted      = 1981;
            Degrees          = "Masters of Dentistry";
            ProfilePhoto     = urlHelper.StaticImage("profone.jpg");

            var address = new AddressViewModel
            {
                Id                     = 1,
                AdressType             = 4,
                Address                = "109 Brilia Private",
                City                   = "Ottawa",
                State                  = "Ontario",
                Country                = "Canada",
                ZipCode                = "K1J0B7",
                AddressTypeDescription = "Home Office"
            };

            address.Format();
            AddressViewModels.Add(address);

            address = new AddressViewModel
            {
                Id                     = 2,
                AdressType             = 1,
                Address                = "1180 Seven Seas Dr",
                City                   = "Lake Buena Vista",
                State                  = "Florida",
                Country                = "Canada",
                ZipCode                = "32830",
                AddressTypeDescription = "Main Office"
            };
            address.Format();
            AddressViewModels.Add(address);


            var phone = new PhoneViewModel
            {
                Id                   = 3,
                PhoneType            = 1,
                PhoneNumber          = "613-853-7078",
                PhoneTypeDescription = "Main Phone"
            };

            phone.Format();
            PhoneViewModels.Add(phone);

            phone = new PhoneViewModel
            {
                Id                   = 4,
                PhoneType            = 3,
                PhoneNumber          = "613-853-8562",
                PhoneTypeDescription = "Residence Phone"
            };
            phone.Format();
            PhoneViewModels.Add(phone);

            var specialtyViewModel = new SpecialtyViewModel
            {
                Id   = 1,
                Name = "Dental Public Health",
                ProfessionalAreaLevel = ProfessionalAreaLevel.Specialty
            };

            SpecialtyViewModels.Add(specialtyViewModel);

            specialtyViewModel = new SpecialtyViewModel
            {
                Id   = 1,
                Name = "Endodontics",
                ProfessionalAreaLevel = ProfessionalAreaLevel.Specialty
            };
            SpecialtyViewModels.Add(specialtyViewModel);

            specialtyViewModel = new SpecialtyViewModel
            {
                Id   = 1,
                Name = "Oral and Maxillofacial Surgery",
                ProfessionalAreaLevel = ProfessionalAreaLevel.Specialty
            };
            SpecialtyViewModels.Add(specialtyViewModel);

            specialtyViewModel = new SpecialtyViewModel
            {
                Id   = 1,
                Name = "Oral Medicine and Pathology",
                ProfessionalAreaLevel = ProfessionalAreaLevel.Specialty
            };
            SpecialtyViewModels.Add(specialtyViewModel);

            specialtyViewModel = new SpecialtyViewModel
            {
                Id   = 1,
                Name = "Oral & Maxillofacial Radiology ",
                ProfessionalAreaLevel = ProfessionalAreaLevel.Specialty
            };

            SpecialtyViewModels.Add(specialtyViewModel);
        }
 public ActionResult Destroy([DataSourceRequest]DataSourceRequest request, SpecialtyViewModel model)
 {
     this.specialtiesService.DeleteById(model.Id);
     RouteValueDictionary routeValues = this.GridRouteValues();
     return this.RedirectToAction("Index", routeValues);
 }
Ejemplo n.º 17
0
        public ActionResult SetSpecialty()
        {
            var model = new SpecialtyViewModel();

            return(View(model));
        }
Ejemplo n.º 18
0
        public SpecialtyEdition()
        {
            InitializeComponent();

            DataContext = new SpecialtyViewModel(this);
        }