Ejemplo n.º 1
0
        public ContactForm SaveContactForm(ContactForm form)
        {
            using (var context = new Data.ContactFormsContext()) {
                context.ContactForms.Add(form);

                context.SaveChanges();
            }
            return(form);
        }
Ejemplo n.º 2
0
        public ContactForm SaveContactForm(ContactForm form)
        {
            using (var context = new Data.ContactFormsContext()) {
                context.ContactForms.Add(form);

                context.SaveChanges();
            }
            return form;
        }
Ejemplo n.º 3
0
        public IEnumerable <ContactForm> GetForms(string filter, int skip, int top, string order = "Date", DateTime?createdFrom = null, DateTime?createdTo = null)
        {
            using (var context = new Data.ContactFormsContext()) {
                IQueryable <ContactForm> forms = null;

                forms = context.ContactForms;

                if (createdFrom.HasValue)
                {
                    forms = forms.Where(f => f.CreateDate >= createdFrom.Value);
                }

                if (createdTo.HasValue)
                {
                    forms = forms.Where(f => f.CreateDate <= createdTo.Value);
                }

                if (!String.IsNullOrEmpty(filter))
                {
                    filter = filter.ToLower();
                    forms  = forms.Where(f =>
                                         f.ContactName.ToLower().Contains(filter) ||
                                         f.ContactEmail.ToLower().Contains(filter) ||
                                         f.ContactPersonalId.ToLower().Contains(filter) ||
                                         f.ContactPersonalId2.ToLower().Contains(filter) ||
                                         f.Subject.ToLower().Contains(filter) ||
                                         f.ShortMessage.ToLower().Contains(filter) ||
                                         f.ContactCountry.ToLower().Equals(filter) ||
                                         f.ContactCity.ToLower().Equals(filter) ||
                                         f.ContactState.ToLower().Equals(filter));
                }

                forms = OrderForms(forms, order);

                if (skip != 0)
                {
                    forms = forms.Skip(skip);
                }

                if (top != 0)
                {
                    forms = forms.Take(top);
                }

                return(forms.ToArray());
            }
        }
Ejemplo n.º 4
0
        public IEnumerable<ContactForm> GetForms(string filter, int skip, int top, string order = "Date", DateTime? createdFrom = null, DateTime? createdTo = null)
        {
            using (var context = new Data.ContactFormsContext()) {
                IQueryable<ContactForm> forms = null;

                forms = context.ContactForms;

                if (createdFrom.HasValue)
                    forms = forms.Where(f => f.CreateDate >= createdFrom.Value);

                if (createdTo.HasValue)
                    forms = forms.Where(f => f.CreateDate <= createdTo.Value);

                if (!String.IsNullOrEmpty(filter)) {
                    filter = filter.ToLower();
                    forms = forms.Where(f =>
                        f.ContactName.ToLower().Contains(filter) ||
                        f.ContactEmail.ToLower().Contains(filter) ||
                        f.ContactPersonalId.ToLower().Contains(filter) ||
                        f.ContactPersonalId2.ToLower().Contains(filter) ||
                        f.Subject.ToLower().Contains(filter) ||
                        f.ShortMessage.ToLower().Contains(filter) ||
                        f.ContactCountry.ToLower().Equals(filter) ||
                        f.ContactCity.ToLower().Equals(filter) ||
                        f.ContactState.ToLower().Equals(filter));
                }

                forms = OrderForms(forms, order);

                if (skip != 0)
                    forms = forms.Skip(skip);

                if (top != 0)
                    forms = forms.Take(top);

                return forms.ToArray();
            }
        }
Ejemplo n.º 5
0
 public ContactForm GetForm(string formId)
 {
     using (var context = new Data.ContactFormsContext()) {
         return(context.ContactForms.Include("Data").SingleOrDefault(f => f.ContactFormUId == formId));
     }
 }
Ejemplo n.º 6
0
 public ContactForm GetForm(string formId)
 {
     using (var context = new Data.ContactFormsContext()) {
         return context.ContactForms.Include("Data").SingleOrDefault(f => f.ContactFormUId == formId);
     }
 }