コード例 #1
0
        protected void DataPortal_Fetch(VacationRequestSearchCriteria criteria)
        {
            RaiseListChangedEvents = false;
            IsReadOnly = false;

            using (var ctx = new VacationManagerContext())
            {
                IList<Persistence.Model.VacationRequestEntity> requests;

                if (criteria == null)
                    requests = ctx.Requests.ToList();
                else
                {
                    var query = ctx.Requests.AsQueryable();
                    if (criteria.GetMine)
                        query = query.Where(x => x.Employee.Id == criteria.EmployeeId);
                    else
                        query = query.Where(x => x.Employee.Manager.Id == criteria.EmployeeId);

                    if (criteria.States != null)
                        query = query.Where(x => criteria.States.Contains(x.State));

                    requests = query.OrderByDescending(x => x.CreationDate)
                        .ToList();
                }

                foreach (var item in requests)
                    Add(DataPortal.Create<VacationRequest>(item));
            }

            IsReadOnly = true;
            RaiseListChangedEvents = true;
        }
コード例 #2
0
        //
        // GET: /Dashboard/
        public ActionResult Index()
        {
            var employeeSituation = _dataService.Fetch<EmployeeSituation>(Configuration.CurrentEmployeeId);

            var pmCriteria = new VacationRequestSearchCriteria
            {
                GetMine = true,
                EmployeeId = Configuration.CurrentEmployeeId,
                States = new[] { VacationRequestState.Submitted },
            };
            _pmRequests = _dataService.FetchList<VacationRequestInfoList, VacationRequest>(pmCriteria);

            var hrCriteria = new VacationRequestSearchCriteria
            {
                GetMine = true,
                States = new[] { VacationRequestState.Approved },
            };
            _hrRequests = _dataService.FetchList<VacationRequestInfoList, VacationRequest>(hrCriteria);

            var model = new Dashboard
            {
                EmployeeStatistics = employeeSituation,
                PmRequests = _pmRequests,
                HrRequests = _hrRequests,
            };

            return View(model);
        }
コード例 #3
0
        private VacationRequestInfoList LoadModel()
        {
            var criteria = new VacationRequestSearchCriteria
            {
                EmployeeId = Configuration.CurrentEmployeeId,
                GetMine = true,
                States = null,
            };

            return _dataService.FetchList<VacationRequestInfoList, VacationRequest>(criteria);
        }
コード例 #4
0
        public IEnumerable<IResult> Populate()
        {
            yield return UiService.ShowBusy();

            var criteria = new VacationRequestSearchCriteria
            {
                GetMine = false,
                EmployeeId = Context.CurrentEmployee.EmployeeId,
                States = new[] { VacationRequestState.Submitted },
            };
            var result = DataService.FetchList<VacationRequestInfoList, VacationRequest>(criteria);
            yield return result;

            yield return UiService.HideBusy();

            if (ReferenceEquals(null, result.Error))
                Items = result.Result;
            else
                yield return UiService.ShowMessageBox(result.Error.Message, GlobalStrings.ErrorCaption);
        }