示例#1
0
        private void LoadFromModel(AttendanceMark model)
        {
            StudentId   = model.StudentId;
            WeekId      = model.WeekId;
            PeriodId    = model.PeriodId;
            CodeId      = model.CodeId;
            Comments    = model.Comments;
            MinutesLate = model.MinutesLate;

            if (model.AttendancePeriod != null)
            {
                AttendancePeriod = new AttendancePeriodModel(model.AttendancePeriod);
            }

            if (model.AttendanceCode != null)
            {
                AttendanceCode = new AttendanceCodeModel(model.AttendanceCode);
            }

            if (model.Student != null)
            {
                Student = new StudentModel(model.Student);
            }

            if (model.Week != null)
            {
                Week = new AttendanceWeekModel(model.Week);
            }
        }
示例#2
0
        public async Task UpdateAttendanceMarks(params AttendanceMarkSummaryModel[] marks)
        {
            using (var unitOfWork = await DataConnectionFactory.CreateUnitOfWork())
            {
                foreach (var model in marks)
                {
                    if (model.CodeId == Guid.Empty)
                    {
                        throw new AttendanceCodeException("Cannot insert blank attendance codes.");
                    }

                    var markInDb = await GetAttendanceMark(model.StudentId, model.WeekId, model.PeriodId);

                    if (markInDb != null && markInDb.Id.HasValue)
                    {
                        markInDb.CodeId      = model.CodeId;
                        markInDb.MinutesLate = model.MinutesLate ?? 0;
                        markInDb.Comments    = model.Comments;

                        var updatedMark = new AttendanceMark
                        {
                            Id          = markInDb.Id.Value,
                            CodeId      = markInDb.CodeId,
                            StudentId   = markInDb.StudentId,
                            WeekId      = markInDb.WeekId,
                            PeriodId    = markInDb.PeriodId,
                            MinutesLate = markInDb.MinutesLate,
                            Comments    = markInDb.Comments
                        };

                        await unitOfWork.AttendanceMarks.Update(updatedMark);
                    }
                    else
                    {
                        var mark = new AttendanceMark
                        {
                            StudentId   = model.StudentId,
                            WeekId      = model.WeekId,
                            PeriodId    = model.PeriodId,
                            CodeId      = model.CodeId,
                            MinutesLate = model.MinutesLate ?? 0,
                            Comments    = model.Comments
                        };

                        unitOfWork.AttendanceMarks.Create(mark);
                    }
                }

                await unitOfWork.SaveChangesAsync();
            }
        }
示例#3
0
        public async Task Save(params AttendanceMarkListModel[] marks)
        {
            foreach (var model in marks)
            {
                var markInDb = await Get(model.StudentId, model.WeekId, model.PeriodId);

                if (markInDb.Id != Guid.Empty)
                {
                    markInDb.Mark        = model.Mark;
                    markInDb.MinutesLate = model.MinutesLate ?? 0;
                    markInDb.Comments    = model.Comments;

                    var updatedMark = new AttendanceMark
                    {
                        Id          = markInDb.Id,
                        Mark        = markInDb.Mark,
                        StudentId   = markInDb.StudentId,
                        WeekId      = markInDb.WeekId,
                        PeriodId    = markInDb.PeriodId,
                        MinutesLate = markInDb.MinutesLate,
                        Comments    = markInDb.Comments
                    };

                    await _attendanceMarkRepository.Update(updatedMark);
                }
                else
                {
                    var mark = new AttendanceMark
                    {
                        StudentId   = model.StudentId,
                        WeekId      = model.WeekId,
                        PeriodId    = model.PeriodId,
                        Mark        = model.Mark,
                        MinutesLate = model.MinutesLate ?? 0,
                        Comments    = model.Comments
                    };

                    _attendanceMarkRepository.Create(mark);
                }
            }

            await _attendanceMarkRepository.SaveChanges();
        }
示例#4
0
 public AttendanceMarkModel(AttendanceMark model) : base(model)
 {
     LoadFromModel(model);
 }