Exemplo n.º 1
0
        public async Task <IActionResult> IndexVisit(string patientSpecialist, string searchString)
        {
            IQueryable <string> SpecialistQuery = from m in _context.Visit
                                                  orderby m.Specialist
                                                  select m.Specialist;

            var visits = from m in _context.Visit
                         select m;

            if (!string.IsNullOrEmpty(searchString))
            {
                visits = visits.Where(s => s.SLName.Contains(searchString));
            }

            if (!string.IsNullOrEmpty(patientSpecialist))
            {
                visits = visits.Where(x => x.Specialist == patientSpecialist);
            }

            var patientSpecialistVM = new SpecialistViewModel
            {
                Specialists = new SelectList(await SpecialistQuery.Distinct().ToListAsync()),
                Visits      = await visits.ToListAsync()
            };

            return(View(patientSpecialistVM));
        }
Exemplo n.º 2
0
        public static MESpecialist ToMESpecialist(this SpecialistViewModel dto)
        {
            MESpecialist entity = new MESpecialist();

            entity.CopyPropertiesFrom(dto);
            return(entity);
        }
Exemplo n.º 3
0
        public ActionResult Save(SpecialistViewModel dto)
        {
            var isCreate = true;

            try
            {
                if (!dto.MESpecialistID.HasValue)
                {
                    _specialistService.Create(dto);
                    TempData["Message"] = "Tạo mới chuyên khoa thành công.";
                }
                else
                {
                    isCreate = false;
                    _specialistService.Update(dto);
                    TempData["Message"] = "Cập nhật chuyên khoa thành công.";
                }
                TempData["Success"] = true;
                return(Redirect("Index"));
            }
            catch (Exception ex)
            {
                ViewBag.Success     = false;
                ViewBag.Message     = isCreate ? "Tạo mới chuyên khoa thất bại, vui lòng thử lại." : "Cập nhật chuyên khoa thất bại, vui lòng thử lại.";
                ViewData["Doctors"] = _doctorService.GetAll().ToList();
                ViewData["Types"]   = _specialistTypeService.GetAll().ToList();
                return(View("Detail", dto));
            }
        }
Exemplo n.º 4
0
        public ActionResult Create()
        {
            ViewBag.ActiveMenu = "specialist-index";
            SpecialistViewModel specialist = new SpecialistViewModel();

            ViewData["Doctors"] = _doctorService.GetAll().ToList();
            ViewData["Types"]   = _specialistTypeService.GetAll().ToList();
            return(View("Detail", specialist));
        }
        public static SpecialistViewModel ToSpecialistViewModel(this MEDoctorSpecialist entity)
        {
            if (entity.MESpecialist == null)
            {
                return(null);
            }
            SpecialistViewModel dto = new SpecialistViewModel();

            dto.CopyPropertiesFrom(entity.MESpecialist);
            dto.MESpecialistID = entity.MESpecialist.MESpecialistID;
            return(dto);
        }
Exemplo n.º 6
0
        public async Task <IActionResult> Specialist(int id)
        {
            var specialist = await _specialistService.FindDetailedAsync(id);

            if (specialist == null)
            {
                return(RedirectToAction("Error", "Home", new { code = 404, message = "Specialist not found.", returnController = "Specialist", returnAction = "ListOfSpecialists" }));
            }

            var model = new SpecialistViewModel(specialist);

            return(View(model));
        }
Exemplo n.º 7
0
 public void Create(SpecialistViewModel dto)
 {
     try
     {
         _specialistRepository.Add(dto.ToMESpecialist());
         _unitOfWork.Commit();
     }
     catch (Exception ex)
     {
         _logService.Create(ex);
         throw ex;
     }
 }
        public static SpecialistViewModel ToSpecialistViewModel(this MESpecialist entity)
        {
            if (entity == null)
            {
                return(null);
            }
            SpecialistViewModel dto = new SpecialistViewModel();

            dto.CopyPropertiesFrom(entity);
            dto.MESpecialistID = entity.MESpecialistID;
            dto.TotalDoctor    = entity.MEDoctorSpecialists.IsNullOrEmpty() ? 0 : entity.MEDoctorSpecialists.Count(x => x.FK_MEDoctorID.HasValue);
            dto.ChiefDoctor    = entity.MEDoctor.ToDoctorViewModel();
            dto.Type           = entity.MESpecialistType.ToSpecialistTypeViewModel();
            dto.Doctors        = entity.MEDoctorSpecialists.IsNullOrEmpty() ? null : entity.MEDoctorSpecialists.Select(x => x.MEDoctor.ToDoctorViewModel().FullUrlImageDoctor()).ToArray();
            return(dto);
        }
Exemplo n.º 9
0
        public SpecialistViewModel Read(SpecialistBindingModel model)
        {
            SpecialistViewModel specialist;

            using (var command = new NpgsqlCommand($"SELECT * FROM specialist WHERE id={model.Id}", source.npgsqlConnection))
            {
                var reader = command.ExecuteReader();
                reader.Read();
                specialist = new SpecialistViewModel
                {
                    Id             = reader.GetInt32(0),
                    Lastname       = reader.GetString(1),
                    Firstname      = reader.GetString(2),
                    Middlename     = reader.GetString(3),
                    ExperienceWork = reader.GetInt32(4),
                    Qualification  = reader.GetString(5)
                };
                reader.Close();
            }
            return(specialist);
        }
Exemplo n.º 10
0
        public SpecialistViewModel Update(SpecialistViewModel dto)
        {
            try
            {
                var entity = _specialistRepository.GetSingleById(dto.MESpecialistID.GetValueOrDefault());
                if (entity == null)
                {
                    throw new Exception("Object not found!");
                }
                entity.CopyPropertiesFrom(dto);

                _specialistRepository.Update(entity);
                _unitOfWork.Commit();

                return(Get(dto.MESpecialistID.GetValueOrDefault()));
            }
            catch (Exception ex)
            {
                _logService.Create(ex);
                throw ex;
            }
        }
 public IActionResult EditSpecialist(SpecialistViewModel specialist)
 {
     specialistManagementService.Update(specialistMapper.MapFrom(specialist));
     return(RedirectToAction("Specialists"));
 }