Ejemplo n.º 1
0
        public static List <RSVP> GetRSVPs(int?count)
        {
            List <RSVP> guestbooks = new List <RSVP>();

            try
            {
                using (var db = new MariaMatteoWedDBEntities())
                {
                    if (count.HasValue)
                    {
                        guestbooks = db.RSVP.OrderByDescending(x => x.DataInsert).Take(count.Value).ToList();
                    }
                    else
                    {
                        guestbooks = db.RSVP.OrderByDescending(x => x.DataInsert).ToList();
                    }
                }
            }
            catch (Exception exc)
            {
                exc.WriteToLog();
                throw exc;
            }
            return(guestbooks);
        }
Ejemplo n.º 2
0
 public static void InsertGuestbook(Guestbook guestbookEntity)
 {
     try
     {
         using (var db = new MariaMatteoWedDBEntities())
         {
             db.Guestbook.Add(guestbookEntity);
             db.SaveChanges();
         }
     }catch (Exception exc)
     {
         exc.WriteToLog();
         throw exc;
     }
 }
Ejemplo n.º 3
0
 public static void InsertRSVP(RSVP rsvpEntity)
 {
     try
     {
         using (var db = new MariaMatteoWedDBEntities())
         {
             db.RSVP.Add(rsvpEntity);
             db.SaveChanges();
         }
     }
     catch (Exception exc)
     {
         exc.WriteToLog();
         throw exc;
     }
 }
Ejemplo n.º 4
0
        public static RSVP GetCurrentRSVPByGUID(string guid)
        {
            RSVP rsvp = null;

            try
            {
                using (var db = new MariaMatteoWedDBEntities())
                {
                    DateTime maxDate = DateTimeUtilities.MaxDateTime();
                    rsvp = db.RSVP.Where(x => x.Guid == guid && x.DataFine == maxDate).FirstOrDefault();
                }
            }
            catch (Exception exc)
            {
                exc.WriteToLog();
                throw exc;
            }
            return(rsvp);
        }
Ejemplo n.º 5
0
        public static void UpdateRSVP(RSVP rsvpEntity, int lastId, string lastGUID)
        {
            try
            {
                using (var db = new MariaMatteoWedDBEntities())
                {
                    DateTime maxDateTime = DateTimeUtilities.MaxDateTime();
                    var      current     = db.RSVP.Where(x => x.IdRsvp == lastId && x.Guid == lastGUID && x.DataFine == maxDateTime).FirstOrDefault();

                    if (current != null)
                    {
                        current.DataFine = rsvpEntity.DataInizio;
                    }
                    db.RSVP.Add(rsvpEntity);
                    db.SaveChanges();
                }
            }
            catch (Exception exc)
            {
                exc.WriteToLog();
                throw exc;
            }
        }