Ejemplo n.º 1
0
 public void CopyFrom(ServiceAttendance model)
 {
     if (model == null)
     {
         throw new ArgumentNullException("model");
     }
     Id = model.Id;
     StudentAssignedOfferingId = model.StudentAssignedOfferingId;
     DateAttended      = model.DateAttended;
     SelectedSubjectId = model.SubjectId;
     Duration          = model.Duration;
     Notes             = model.Notes;
     if (Audit == null)
     {
         Audit = new AuditModel();
     }
     Audit.CreatedBy  = model.CreatingUser.DisplayName;
     Audit.CreateTime = model.CreateTime;
     if (model.LastModifyingUser != null)
     {
         Audit.LastModifiedBy = model.LastModifyingUser.DisplayName;
         Audit.LastModifyTime = model.LastModifyTime;
     }
     else
     {
         Audit.LastModifiedBy = null;
         Audit.LastModifyTime = null;
     }
 }
Ejemplo n.º 2
0
 public void CopyFrom(StudentAssignedOffering model)
 {
     if (model == null)
     {
         throw new ArgumentNullException("model");
     }
     Id        = model.Id;
     Name      = model.ServiceOffering.Name;
     StartDate = model.StartDate;
     EndDate   = model.EndDate;
     Notes     = model.Notes;
     if (Audit == null)
     {
         Audit = new AuditModel();
     }
     Audit.CreatedBy  = model.CreatingUser.DisplayName;
     Audit.CreateTime = model.CreateTime;
     if (model.LastModifyingUser != null)
     {
         Audit.LastModifiedBy = model.LastModifyingUser.DisplayName;
         Audit.LastModifyTime = model.LastModifyTime;
     }
     else
     {
         Audit.LastModifiedBy = null;
         Audit.LastModifyTime = null;
     }
 }
        public void GivenModelHasAuditData_WhenCopyFrom_ThenModelStateSet()
        {
            ServiceRequest expectedState = new ServiceRequest
            {
                PriorityId         = 1,
                SubjectId          = 1,
                FulfillmentDetails = new List <ServiceRequestFulfillment> {
                    new ServiceRequestFulfillment {
                        FulfillmentStatusId = 1
                    }
                },
                CreateTime   = new DateTime(2005, 4, 30),
                CreatingUser = new User {
                    DisplayName = "fredBob"
                },
                LastModifyTime    = new DateTime(2010, 5, 13),
                LastModifyingUser = new User {
                    DisplayName = "jimGeorge"
                }
            };
            ServiceRequestModel target = new ServiceRequestModel();

            target.CopyFrom(expectedState);

            AuditModel actualState = target.Audit;

            Assert.AreEqual(expectedState.CreateTime, actualState.CreateTime);
            Assert.AreEqual(expectedState.CreatingUser.DisplayName, actualState.CreatedBy);
            Assert.AreEqual(expectedState.LastModifyTime, actualState.LastModifyTime);
            Assert.AreEqual(expectedState.LastModifyingUser.DisplayName, actualState.LastModifiedBy);
        }
Ejemplo n.º 4
0
 public virtual void CopyFrom(CustomField model)
 {
     if (model == null)
     {
         throw new ArgumentNullException("model");
     }
     Id                  = model.Id;
     FieldName           = model.Name;
     SelectedCategories  = model.Categories.Select(c => c.Id);
     SelectedFieldTypeId = model.CustomFieldTypeId;
     if (Audit == null)
     {
         Audit = new AuditModel();
     }
     Audit.CreatedBy  = model.CreatingUser.DisplayName;
     Audit.CreateTime = model.CreateTime;
     if (model.LastModifyingUser != null)
     {
         Audit.LastModifiedBy = model.LastModifyingUser.DisplayName;
         Audit.LastModifyTime = model.LastModifyTime;
     }
     else
     {
         Audit.LastModifiedBy = null;
         Audit.LastModifyTime = null;
     }
 }
        public void GivenModelHasAuditData_WhenCopyFrom_ThenModelStateSet()
        {
            var expected = TestData.Eulas[0];

            Target.CopyFrom(expected);

            AuditModel actualState = Target.Audit;

            Assert.AreEqual(expected.CreateTime, actualState.CreateTime);
            Assert.AreEqual(expected.CreatingUser.DisplayName, actualState.CreatedBy);
        }
Ejemplo n.º 6
0
 public void CopyFrom(EulaAgreement model)
 {
     if (model == null)
     {
         throw new ArgumentNullException("model");
     }
     Id       = model.Id;
     EulaText = model.EulaText;
     if (Audit == null)
     {
         Audit = new AuditModel();
     }
     Audit.CreatedBy  = model.CreatingUser.DisplayName;
     Audit.CreateTime = model.CreateTime;
 }
        public void CopyFrom(ServiceRequest model)
        {
            if (model == null)
            {
                throw new ArgumentNullException("model");
            }
            Id         = model.Id;
            StudentIds = new List <int>()
            {
                model.StudentId
            };
            SelectedPriorityId    = model.PriorityId;
            SelectedServiceTypeId = model.ServiceTypeId;
            SelectedSubjectId     = model.SubjectId;
            Notes = model.Notes;
            var latestDetail = model.FulfillmentDetails.OrderByDescending(f => f.CreateTime).First();

            SelectedAssignedOfferingId = latestDetail.FulfilledById;
            SelectedStatusId           = latestDetail.FulfillmentStatusId;
            OriginalStatusId           = SelectedStatusId;
            FulfillmentNotes           = latestDetail.Notes;
            if (Audit == null)
            {
                Audit = new AuditModel();
            }
            Audit.CreatedBy  = model.CreatingUser.DisplayName;
            Audit.CreateTime = model.CreateTime;
            if (model.LastModifyingUser != null)
            {
                Audit.LastModifiedBy = model.LastModifyingUser.DisplayName;
                Audit.LastModifyTime = model.LastModifyTime;
            }
            else
            {
                Audit.LastModifiedBy = null;
                Audit.LastModifyTime = null;
            }
        }
Ejemplo n.º 8
0
        public void GivenModelHasAuditData_WhenCopyFrom_ThenModelStateSet()
        {
            CustomField expectedState = new PublicField
            {
                CreateTime   = new DateTime(2005, 4, 30),
                CreatingUser = new User {
                    DisplayName = "fredBob"
                },
                LastModifyTime    = new DateTime(2010, 5, 13),
                LastModifyingUser = new User {
                    DisplayName = "jimGeorge"
                }
            };
            CustomFieldModel target = new PublicFieldModel();

            target.CopyFrom(expectedState);

            AuditModel actualState = target.Audit;

            Assert.AreEqual(expectedState.CreateTime, actualState.CreateTime);
            Assert.AreEqual(expectedState.CreatingUser.DisplayName, actualState.CreatedBy);
            Assert.AreEqual(expectedState.LastModifyTime, actualState.LastModifyTime);
            Assert.AreEqual(expectedState.LastModifyingUser.DisplayName, actualState.LastModifiedBy);
        }
        public void GivenModelHasAuditData_WhenCopyFrom_ThenModelStateSet()
        {
            StudentAssignedOffering expectedState = new StudentAssignedOffering
            {
                ServiceOffering = new ServiceOffering
                {
                    Provider = new Provider {
                        Name = "provider name"
                    },
                    ServiceType = new ServiceType {
                        Name = "service type name"
                    },
                    Program = new Program {
                        Name = "program name"
                    }
                },
                CreateTime   = new DateTime(2005, 4, 30),
                CreatingUser = new User {
                    DisplayName = "fredBob"
                },
                LastModifyTime    = new DateTime(2010, 5, 13),
                LastModifyingUser = new User {
                    DisplayName = "jimGeorge"
                }
            };
            StudentServiceOfferingScheduleModel target = new StudentServiceOfferingScheduleModel();

            target.CopyFrom(expectedState);

            AuditModel actualState = target.Audit;

            Assert.AreEqual(expectedState.CreateTime, actualState.CreateTime);
            Assert.AreEqual(expectedState.CreatingUser.DisplayName, actualState.CreatedBy);
            Assert.AreEqual(expectedState.LastModifyTime, actualState.LastModifyTime);
            Assert.AreEqual(expectedState.LastModifyingUser.DisplayName, actualState.LastModifiedBy);
        }