Bzs.Server.ServerService.LessonServerService.GetLessonsOfDayToDisplay C# (CSharp) Method

GetLessonsOfDayToDisplay() public method

Returns the lessons of a day to display.
public GetLessonsOfDayToDisplay ( System.Guid dayId, System.Guid accountId ) : List
dayId System.Guid The day identifier.
accountId System.Guid The account identifier.
return List
        public List<LessonDisplayDto> GetLessonsOfDayToDisplay(Guid dayId, Guid accountId)
        {
            List<LessonDisplayDto> data = new List<LessonDisplayDto>();
            using (BzsEntityContainer ctx = this.CreateContainer())
            {
                IQueryable<LessonEntity> entities = ctx.LessonSet.Where(f => f.DayId == dayId && f.AccountId == accountId);
                foreach (LessonEntity entity in entities)
                {
                    LessonDisplayDto item = new LessonDisplayDto();
                    item.Id = entity.Id;
                    item.DayId = entity.DayId;
                    item.DayCaption = entity.DayNavProp.Caption;
                    item.FromDate = DateTimeHelper.DateTimeToString(entity.FromDate);
                    item.ToDate = DateTimeHelper.DateTimeToString(entity.ToDate);
                    item.SubjectCode = entity.SubjectNavProp.Code;
                    item.SubjectCaption = entity.SubjectNavProp.Caption;
                    item.TeacherCode = entity.TeacherNavProp.Code;
                    item.TeacherCaption = entity.TeacherNavProp.Caption;
                    item.RoomCode = entity.RoomNavProp.Code;
                    item.RoomCaption = entity.RoomNavProp.Caption;
                    item.Remark = entity.Remark;

                    data.Add(item);
                }
            }

            return data;
        }

Usage Example

        /// <summary>
        /// Returns the lesson of a day to display.
        /// </summary>
        /// <param name="id">The day identifier.</param>
        /// <returns>The lessons.</returns>
        public List<LessonDisplayDto> GetLessonOfDayToDisplay(string id)
        {
            this.SetResponseHeaderCacheExpiration();

            AccountPassword credentials = this.GetCredentialsFromRequest();
            AccountServerService accountService = new AccountServerService();
            Guid accountId = accountService.GetAccountId(credentials.Account);

            LessonServerService service = new LessonServerService();
            return service.GetLessonsOfDayToDisplay(new Guid(id), accountId);
        }