public void Handle(CreateActivityValues command) { if (command == null) { throw new ArgumentNullException("command"); } var activityValues = new ActivityValues { ActivityId = command.ActivityId, Title = command.Title, Content = command.Content, StartsOn = command.StartsOn, EndsOn = command.EndsOn, OnGoing = command.OnGoing, StartsFormat = command.StartsOn.HasValue ? command.StartsFormat ?? "M/d/yyyy" : null, EndsFormat = command.EndsOn.HasValue ? command.EndsFormat ?? "M/d/yyyy" : null, Mode = command.Mode, WasExternallyFunded = command.WasExternallyFunded, WasInternallyFunded = command.WasInternallyFunded, CreatedByPrincipal = command.Principal.Identity.Name, }; _entities.Create(activityValues); command.CreatedActivityValues = activityValues; if (!command.NoCommit) { _entities.SaveChanges(); } }
protected internal Activity() { EntityId = Guid.NewGuid(); Mode = ActivityMode.Draft; DraftedValues = new ActivityValues(); Values = new ActivityValues(); CreatedOn = DateTime.UtcNow; UpdatedOn = DateTime.UtcNow; // ReSharper disable DoNotCallOverridableMethodsInConstructor DraftedTags = new Collection <DraftedTag>(); Tags = new Collection <ActivityTag>(); // ReSharper restore DoNotCallOverridableMethodsInConstructor }
protected internal Activity() { EntityId = Guid.NewGuid(); Mode = ActivityMode.Draft; DraftedValues = new ActivityValues(); Values = new ActivityValues(); CreatedOn = DateTime.UtcNow; UpdatedOn = DateTime.UtcNow; // ReSharper disable DoNotCallOverridableMethodsInConstructor DraftedTags = new Collection<DraftedTag>(); Tags = new Collection<ActivityTag>(); // ReSharper restore DoNotCallOverridableMethodsInConstructor }
internal static bool IsEmpty(this ActivityValues entity) { var isEmpty = true; isEmpty &= string.IsNullOrWhiteSpace(entity.Title); isEmpty &= string.IsNullOrWhiteSpace(entity.Content); isEmpty &= !entity.StartsOn.HasValue; isEmpty &= !entity.EndsOn.HasValue; isEmpty &= !entity.OnGoing.HasValue; isEmpty &= entity.Locations == null || entity.Locations.Count == 0; isEmpty &= entity.Types == null || entity.Types.Count == 0; isEmpty &= entity.Tags == null || entity.Tags.Count == 0; isEmpty &= entity.Documents == null || entity.Documents.Count == 0; isEmpty &= !entity.WasExternallyFunded.HasValue; isEmpty &= !entity.WasInternallyFunded.HasValue; return(isEmpty); }
protected bool Equals(ActivityValues other) { bool equal = true; equal &= Equals(Title, other.Title); equal &= string.Equals(Content, other.Content); equal &= StartsOn.Equals(other.StartsOn); equal &= EndsOn.Equals(other.EndsOn); equal &= EqualsNullableBool(OnGoing, other.OnGoing); equal &= string.Equals(DateFormat, other.DateFormat); equal &= Locations.OrderBy(a => a.PlaceId).SequenceEqual(other.Locations.OrderBy(b => b.PlaceId)); equal &= Types.OrderBy(a => a.TypeId).SequenceEqual(other.Types.OrderBy(b => b.TypeId)); equal &= Tags.OrderBy(a => a.Text).SequenceEqual(other.Tags.OrderBy(b => b.Text)); equal &= Documents.OrderBy(a => a.Title).SequenceEqual(other.Documents.OrderBy(b => b.Title)); equal &= string.Equals(ModeText, other.ModeText); equal &= EqualsNullableBool(WasExternallyFunded, other.WasExternallyFunded); equal &= EqualsNullableBool(WasInternallyFunded, other.WasInternallyFunded); return equal; }
internal CreateActivityDocument(IPrincipal principal, ActivityValues activityValues) : this(principal, 0) { ActivityValues = activityValues; Mode = activityValues.Mode; }
public void Set(ActivityValues v) { if (v == null) return; Title = v.Title; Content = v.Content; StartsOn = v.StartsOn; EndsOn = v.EndsOn; OnGoing = v.OnGoing; Locations = v.Locations; Types = v.Types; Tags = v.Tags; Documents = v.Documents; Mode = v.Mode; WasExternallyFunded = v.WasExternallyFunded; WasInternallyFunded = v.WasInternallyFunded; }