public IActionResult CalendarTimeline(DateTime requestDate, int departmentId)
        {
            var trust = trustService.GetTrustById(IsPharmixAdmin? HttpContext.Session.GetInt32("TrustID") ?? 1: trustService.GetTrustIdByUser(CurrentUserName));
            var model = SchServ.GetCalendarTimeline(requestDate, trust, departmentId);

            model.EnableIntervalConfig = IsTrustAdmin || IsPharmixAdmin;

            return(PartialView("_CalendarTimeline", model));
        }
        public TrustViewModel GetTrustModules(int trustId)
        {
            TrustViewModel trustViewModel = new TrustViewModel();

            if (trustId > 0)
            {
                var trust = _trustService.GetTrustById(trustId);

                trustViewModel.Id   = trustId;
                trustViewModel.Name = trust.Name;

                var trustModuleViewModelList = (from m in _context.Modules
                                                join tm in _context.TrustModules on new { mid = m.Id, tid = trustId } equals new { mid = tm.ModuleId, tid = tm.TrustId } into tmdef
                                                from tm in tmdef.DefaultIfEmpty()
                                                select new TrustModuleViewModel
                {
                    Id = tm != null ? tm.Id : 0,
                    ModuleId = m.Id,
                    ModuleName = m.Name,
                    TrustId = tm != null ? tm.TrustId : 0,
                    IsHaveAccess = tm != null
                }).ToList();

                trustViewModel.TrustModuleViewModelList = trustModuleViewModelList;
            }
            return(trustViewModel);
        }
        public object SaveAppointmentInterval(AppointmentIntervalViewModel model, string user)
        {
            var trust = trustService.GetTrustById(model.TrustId);

            if (trust == null)
            {
                return new { IsSuccess = false, Message = "Appointment intervals save failed" }
            }
            ;

            if (repository.GetContext().PatientAppointments.Any(p => !p.IsArchived))
            {
                return(new { IsSuccess = false, Message = "One or more appointments have been scheduled. Intervals can be updated only when there is no appointments scheduled in the system." });
            }

            trust = Mapper.Map(model, trust);

            trust.SetUpdateDetails(user);
            repository.SaveExisting(trust);

            return(new { IsSuccess = true, Message = "Appointment intervals saved successfully" });
        }
    }