Ejemplo n.º 1
0
        public static Entities.StudentIEP CreateStudentIEP(StudentIEPModel model, int userId)
        {
            Debug.Assert(model.ScheduledDate != null, "model.ScheduledDate != null");
            Debug.Assert(model.ScheduledDateTime != null, "model.ScheduledDateTime != null");

            var result = new Entities.StudentIEP
            {
                CreatedBy      = userId,
                CreatedOn      = DateTime.Now,
                LastModifiedBy = userId,
                LastModifiedOn = DateTime.Now,
                DateOfMeeting  = Misc.CombineDateAndTime(model.DateOfMeeting, model.DateOfMeetingTime),
                IsComplete     = model.IsComplete,
                IsCurrentIEP   = model.IsCurrent,
                ScheduledDate  = Misc.CombineDateAndTime(model.ScheduledDate.Value, model.ScheduledDateTime.Value),
                StudentId      = model.StudentId
            };

            using (var context = DataContext.GetContext())
            {
                context.StudentIEPs.AddObject(result);
                context.SaveChanges();

                if (model.StudentDocumentId.HasValue)
                {
                    var studentDocument = context.StudentDocuments.Single(a => a.StudentDocumentId == model.StudentDocumentId.Value);
                    studentDocument.StudentIEPId = result.StudentIEPId;
                    context.SaveChanges();
                }
            }

            return(result);
        }
Ejemplo n.º 2
0
        public static Entities.StudentIEP CreateStudentIEP(StudentIEPModel model, int userId)
        {
            Debug.Assert(model.ScheduledDate != null, "model.ScheduledDate != null");
            Debug.Assert(model.ScheduledDateTime != null, "model.ScheduledDateTime != null");

            var result = new Entities.StudentIEP
            {
                CreatedBy = userId,
                CreatedOn = DateTime.Now,
                LastModifiedBy = userId,
                LastModifiedOn = DateTime.Now,
                DateOfMeeting = Misc.CombineDateAndTime(model.DateOfMeeting, model.DateOfMeetingTime),
                IsComplete = model.IsComplete,
                IsCurrentIEP = model.IsCurrent,
                ScheduledDate = Misc.CombineDateAndTime(model.ScheduledDate.Value, model.ScheduledDateTime.Value),
                StudentId = model.StudentId
            };
            using (var context = DataContext.GetContext())
            {
                context.StudentIEPs.AddObject(result);
                context.SaveChanges();

                if (model.StudentDocumentId.HasValue)
                {
                    var studentDocument = context.StudentDocuments.Single(a => a.StudentDocumentId == model.StudentDocumentId.Value);
                    studentDocument.StudentIEPId = result.StudentIEPId;
                    context.SaveChanges();
                }
            }

            return result;
        }