Exemplo n.º 1
0
        public async Task <DashboardActivityRecordViewModel> GetActivityRecords()
        {
            var queryFactory            = _dataAccess.GetQueryFactory(_connectionString);
            var items                   = (await queryFactory.Query(TableConstants.ActivityRecordTable).GetAsync()).Cast <IDictionary <string, object> >().ToList();
            var dashboardActivityRecord = new DashboardActivityRecordViewModel();

            foreach (var item in items)
            {
                var dashboardActivityRecordItem = new DashboardActivityRecordItemViewModel()
                {
                    MyId    = (int)item[ActivityRecordConstants.Id],
                    MyDate  = (DateTime)item[ActivityRecordConstants.Date],
                    MyTitle = (string)item[ActivityRecordConstants.Title]
                };
                dashboardActivityRecord.OurDashboardActivityRecords.Add(dashboardActivityRecordItem);
            }
            return(dashboardActivityRecord);
        }
Exemplo n.º 2
0
        public async Task <DashboardActivityRecordViewModel> GetActivityRecords(int userId)
        {
            var queryFactory   = _dataAccess.GetQueryFactory(_connectionString);
            var activityRecord = queryFactory.Query(TableConstants.ActivityRecordTable);
            var memberQuery    = queryFactory.Query(TableConstants.MembersTable)
                                 .Where(MemberConstants.UserId, userId)
                                 .IncludeMany(TableConstants.ActivityRecordTable, activityRecord,
                                              ActivityRecordConstants.ProjectId, MemberConstants.ProjectId);

            var items = (await memberQuery.GetAsync()).Cast <IDictionary <string, object> >().ToList();
            var dashboardActivityRecord = new DashboardActivityRecordViewModel();

            foreach (var item in items)
            {
                var activityRecordDictionaries =
                    (IEnumerable <IDictionary <string, object> >)item[TableConstants.ActivityRecordTable];


                foreach (var activityRecordDictionary in activityRecordDictionaries)
                {
                    var creatorId = (int)activityRecordDictionary[ActivityRecordConstants.CreatorId];

                    var dashboardActivityRecordItem = new DashboardActivityRecordItemViewModel
                    {
                        MyId        = (int)activityRecordDictionary[ActivityRecordConstants.Id],
                        MyDate      = (DateTime)activityRecordDictionary[ActivityRecordConstants.Date],
                        MyTitle     = (string)activityRecordDictionary[ActivityRecordConstants.Title],
                        MyProjectId = (int)activityRecordDictionary[ActivityRecordConstants.ProjectId],
                        MyCreatorId = creatorId,
                        CanView     = true,
                        CanDelete   = creatorId == userId,
                        CanEdit     = creatorId == userId
                    };
                    dashboardActivityRecord.OurDashboardActivityRecords.Add(dashboardActivityRecordItem);
                }
            }
            return(dashboardActivityRecord);
        }