Example #1
0
        /// <summary>
        /// Prepare paged doctor list model
        /// </summary>
        /// <param name="searchModel">Doctor search model</param>
        /// <returns>Doctor list model</returns>
        public virtual DoctorListModel PrepareDoctorListModel(DoctorSearchModel searchModel)
        {
            if (searchModel == null)
            {
                throw new ArgumentNullException(nameof(searchModel));
            }

            var entities = _doctorService.GetAll(keyWord: searchModel.SearchName,
                                                 pageIndex: searchModel.Page - 1,
                                                 pageSize: searchModel.PageSize,
                                                 showHidden: true);

            //var model = new DoctorListModel
            //{
            //    Data = entities.PaginationByRequestModel(searchModel).Select(s =>
            //    {
            //        //fill in model values from the entity
            //        var customerRoleModel = s.ToModel<DoctorModel>();
            //        return customerRoleModel;
            //    }),
            //    Total = entities.TotalCount
            //};

            //prepare list model
            var model = new DoctorListModel
            {
                //fill in model values from the entity
                Data  = entities.Select(x => x.ToModel <DoctorModel>()),
                Total = entities.TotalCount
            };

            return(model);
        }
Example #2
0
        public async Task <IActionResult> Search([FromBody] DoctorSearchModel model)
        {
            try
            {
                var doctors = from m in _context.Doctors
                              select m;

                if (!string.IsNullOrEmpty(model.LastName))
                {
                    doctors = doctors.Where(x => EF.Functions.Like(x.LastName, $"%{model.LastName}%"));
                }

                if (!string.IsNullOrEmpty(model.FirstName))
                {
                    doctors = doctors.Where(x => EF.Functions.Like(x.FirstName, $"%{model.FirstName}%"));
                }

                if (!string.IsNullOrEmpty(model.MiddleName))
                {
                    doctors = doctors.Where(x => EF.Functions.Like(x.MiddleName, $"%{model.MiddleName}%"));
                }

                if (model.SpecializationId > 0)
                {
                    doctors = doctors.Where(x => x.SpecializationId == model.SpecializationId);
                }

                return(Ok(await doctors.Include(x => x.Specialization).ToListAsync()));
            }
            catch (Exception)
            {
                return(StatusCode(500));
            }
        }
Example #3
0
        public ActionResult Search(DoctorSearchModel model)
        {
            model = model ?? new DoctorSearchModel();
            var doctors = _doctorService.GetAllDoctors(model.AreaName, model.SpecialtyName, model.DoctorName).ToList();

            model.DoctorCollection = doctors.ToPagedList(model.Page, model.PageSize);
            return(View(model));
        }
Example #4
0
        /// <summary>
        /// Prepare doctor search model
        /// </summary>
        /// <param name="searchModel">Doctor search model</param>
        /// <returns>Doctor search model</returns>
        public virtual DoctorSearchModel PrepareDoctorSearchModel(DoctorSearchModel searchModel)
        {
            if (searchModel == null)
            {
                throw new ArgumentNullException(nameof(searchModel));
            }
            //prepare page parameters
            searchModel.SetGridPageSize();

            return(searchModel);
        }
Example #5
0
        public virtual DoctorSearchModel PrepareDoctorSearchModel(DoctorSearchModel searchModel)
        {
            if (searchModel == null)
            {
                throw new ArgumentNullException(nameof(searchModel));
            }

            //get doctor
            //var doctors =
            return(searchModel);
        }
        public virtual IQueryable <Doctor> SearchDoctor(DoctorSearchModel model)
        {
            var name         = new SqlParameter("@name", (object)model.Name ?? DBNull.Value);
            var specialtyId  = new SqlParameter("@specialtyId", (object)model.SpecialtyId ?? DBNull.Value);
            var hospitalId   = new SqlParameter("@hospitalId", (object)model.HospitalId ?? DBNull.Value);
            var departmentId = new SqlParameter("@departmentId", (object)model.DepartmentId ?? DBNull.Value);

            var doctors = Doctors.FromSqlRaw("SELECT * FROM SearchDoctors(@name, @specialtyId, @hospitalId, @departmentId)",
                                             name, specialtyId, hospitalId, departmentId);

            return(doctors);
        }
Example #7
0
        public virtual IActionResult List(DoctorSearchModel searchModel)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageDoctors))
            {
                return(AccessDeniedKendoGridJson());
            }

            //prepare model
            var model = _doctorModelFactory.PrepareDoctorListModel(searchModel);

            return(Json(model));
        }
Example #8
0
 public async Task <IEnumerable <Doctor> > SearchDoctors(DoctorSearchModel model) => await db.SearchDoctor(model)
 .Include(d => d.Person).ThenInclude(p => p.Address).ThenInclude(a => a.Country)
 .Include(d => d.Person).ThenInclude(p => p.Address).ThenInclude(a => a.Region)
 .Include(d => d.Person).ThenInclude(p => p.Address).ThenInclude(a => a.District)
 .Include(d => d.Person).ThenInclude(p => p.Address).ThenInclude(a => a.City)
 .Include(d => d.Person).ThenInclude(p => p.Address).ThenInclude(a => a.Street)
 .Include(d => d.Person).ThenInclude(p => p.CountryOfBirth)
 .Include(d => d.Person).ThenInclude(p => p.PlaceOfBirth)
 .Include(d => d.Person).ThenInclude(p => p.Gender)
 .Include(d => d.Person).ThenInclude(p => p.Phones).ThenInclude(p => p.Phone)
 .Include(d => d.Person).ThenInclude(p => p.Emails).ThenInclude(e => e.Email)
 .Include(d => d.Person).ThenInclude(p => p.Documents).ThenInclude(d => d.DocumentType)
 .Include(d => d.DoctorSpecialties).ThenInclude(s => s.Specialty)
 .Include(d => d.DoctorPositions).ThenInclude(p => p.Position)
 .Include(d => d.DoctorPositions).ThenInclude(p => p.Specialty)
 .Include(d => d.DoctorPositions).ThenInclude(p => p.Hospital)
 .Include(d => d.DoctorPositions).ThenInclude(p => p.Department)
 .Include(d => d.Diplomas)
 .AsNoTracking().ToListAsync();
Example #9
0
 public async Task <IEnumerable <Doctor> > Search(DoctorSearchModel model) => await _repository.SearchDoctors(model);
Example #10
0
 public HomeController()
 {
     _doctorSearchModel = new DoctorSearchModel();
     _doctorService     = new DoctorService();
 }