예제 #1
0
 public virtual bool Remove(params T[] items)
 {
     using (var context = new GarageSaleDataContext(this.userID))
     {
         foreach (T item in items)
         {
             context.Entry(item).State = EntityState.Deleted;
         }
         context.SaveChanges();
     }
     return(true);
 }
예제 #2
0
        public static void SendNotifications(string dummy)
        {
            string emailaddress, subject, mytemplate = "";

            Console.Write("Waypoint 1");

            GarageSaleDataContext db = new GarageSaleDataContext();

            var linqMailTemplates = db.sp_getTemplate(1);
            foreach (var linqMailTemplate in linqMailTemplates)
            {
                mytemplate = linqMailTemplate.TemplateText;
            }

            int itemid = 0;
            string conversation = "";
            var linqMembers = db.sp_whatMailToSent();
            foreach (var linqMember in linqMembers)
            {
                var sendtemplate = mytemplate;
                emailaddress = linqMember.EmailAddress;
                subject = linqMember.ItemName;

                if (linqMember.ItemID != itemid)
                {
                    conversation = "";
                    var linqMessages = db.sp_EmailDetails(linqMember.ItemID);
                    foreach (var linqMessage in linqMessages)
                    {
                        if (linqMessage.Seller == 1)
                        {
                            conversation += "<b>Seller</b>" + linqMessage.DateInserted + "<br />";
                        }
                        else
                        {
                            conversation += "<b>Buyer</b>" + linqMessage.DateInserted + "<br />";
                        }
                        conversation += linqMessage.MessageText;
                        conversation += "<br /><br />";
                    }
                    itemid = Convert.ToInt32(linqMember.ItemID);
                }

                sendtemplate = sendtemplate.Replace("#Conversation", conversation);
                sendtemplate = sendtemplate.Replace("#ItemName", linqMember.ItemName);

                var linqUpdateEmailTrack = db.sp_UpdateEmailTrack(itemid, emailaddress);

                SendMail(emailaddress, subject, sendtemplate);
            }
        }
예제 #3
0
        public virtual IList <T> GetAll(params Expression <Func <T, object> >[] navigationProperties)
        {
            List <T> list;

            using (var context = new GarageSaleDataContext(this.userID))
            {
                IQueryable <T> dbQuery = context.Set <T>();

                //Apply eager loading
                foreach (Expression <Func <T, object> > navigationProperty in navigationProperties)
                {
                    dbQuery = dbQuery.Include <T, object>(navigationProperty);
                }

                list = dbQuery
                       .AsNoTracking()
                       .ToList <T>();
            }
            return(list);
        }
예제 #4
0
        public virtual T GetSingle(Func <T, bool> where,
                                   params Expression <Func <T, object> >[] navigationProperties)
        {
            T item = null;

            using (var context = new GarageSaleDataContext(this.userID))
            {
                IQueryable <T> dbQuery = context.Set <T>();

                //Apply eager loading
                foreach (Expression <Func <T, object> > navigationProperty in navigationProperties)
                {
                    dbQuery = dbQuery.Include <T, object>(navigationProperty);
                }

                item = dbQuery
                       .AsNoTracking()         //Don't track any changes for the selected item
                       .FirstOrDefault(where); //Apply where clause
            }
            return(item);
        }