Ejemplo n.º 1
0
 public Subscription(Guid id) : base(id)
 {
     Contact   = new ForeignKeyField <Contact, Subscription>(this, "contactid", false, p => p.Subscriptions);
     Feed      = new ForeignKeyField <Feed, Subscription>(this, "feedid", false, null);
     StartDate = new Field <DateTime>(this, "startdate", DateTime.UtcNow);
     EndDate   = new FieldNull <DateTime>(this, "enddate");
 }
Ejemplo n.º 2
0
 public void AddAssignTimeString(string fieldName, FieldNull <DateTime> field, string stringValue)
 {
     if (!string.IsNullOrEmpty(stringValue))
     {
         if (field.Value.HasValue &&
             TimeSpan.TryParseExact(stringValue,
                                    new string[] {
             @"hh\:mm",
             @"h\:mm",
         },
                                    CultureInfo.InvariantCulture,
                                    out TimeSpan value))
         {
             field.Value = field.Value.Value.Add(value);
         }
         else
         {
             Add(fieldName,
                 "Validation.Time.Invalid",
                 "Validation message on time invalid",
                 "Time invalid");
             IsSuccess = false;
         }
     }
     else
     {
         Add(fieldName,
             "Validation.Time.Required",
             "Validation message on time required",
             "Time required");
         IsSuccess = false;
     }
 }
Ejemplo n.º 3
0
 public Sending(Guid id) : base(id)
 {
     Mailing        = new ForeignKeyField <Mailing, Sending>(this, "mailingid", false, null);
     Address        = new ForeignKeyField <ServiceAddress, Sending>(this, "addressid", false, null);
     Status         = new EnumField <SendingStatus>(this, "status", SendingStatus.Created, SendingStatusExtensions.Translate);
     SentDate       = new FieldNull <DateTime>(this, "sentdate");
     FailureMessage = new StringNullField(this, "failuremessage", 256);
 }
Ejemplo n.º 4
0
 public Mailing(Guid id) : base(id)
 {
     Title             = new StringField(this, "title", 256);
     RecipientFeed     = new ForeignKeyField <Feed, Mailing>(this, "recipientfeedid", false, null);
     RecipientTag      = new ForeignKeyField <Tag, Mailing>(this, "recipienttagid", true, null);
     RecipientLanguage = new EnumNullField <Language>(this, "recipientlanguage", LanguageExtensions.Translate);
     Sender            = new ForeignKeyField <Group, Mailing>(this, "senderid", false, null);
     Creator           = new ForeignKeyField <User, Mailing>(this, "creatorid", false, null);
     Header            = new ForeignKeyField <MailingElement, Mailing>(this, "headerid", true, null);
     Footer            = new ForeignKeyField <MailingElement, Mailing>(this, "footerid", true, null);
     Subject           = new StringField(this, "subject", 256);
     HtmlText          = new StringField(this, "htmltext", 33554432, AllowStringType.SafeHtml);
     PlainText         = new StringField(this, "plaintext", 33554432, AllowStringType.SafeHtml);
     CreatedDate       = new Field <DateTime>(this, "createddate", DateTime.UtcNow);
     SendingDate       = new FieldNull <DateTime>(this, "sendingdate");
     SentDate          = new FieldNull <DateTime>(this, "sentdate");
     Status            = new EnumField <MailingStatus>(this, "status", MailingStatus.New, MailingStatusExtensions.Translate);
 }
Ejemplo n.º 5
0
 public void AssignDateString(string fieldName, FieldNull <DateTime> field, string stringValue, bool notNull = false)
 {
     if (!string.IsNullOrEmpty(stringValue))
     {
         if (DateTime.TryParseExact(stringValue,
                                    new string[] {
             "yyyy-MM-dd",
             "dd.MM.yyyy",
             "MM/dd/yyyy",
         },
                                    CultureInfo.InvariantCulture,
                                    DateTimeStyles.AssumeLocal,
                                    out DateTime value))
         {
             field.Value = value;
         }
         else
         {
             Add(fieldName,
                 "Validation.Date.Invalid",
                 "Validation message on date invalid",
                 "Date invalid");
             IsSuccess = false;
         }
     }
     else if (notNull)
     {
         Add(fieldName,
             "Validation.Date.Required",
             "Validation message on date required",
             "Date required");
         IsSuccess = false;
     }
     else
     {
         field.Value = null;
     }
 }