示例#1
0
 public static Event DinnerToEvent(Dinner dinner, iCalendar iCal)
 {
     string eventLink = "http://nrddnr.com/" + dinner.DinnerID;
     Event evt = iCal.Create<Event>();
     evt.Start = dinner.EventDate;
     evt.Duration = new TimeSpan(3, 0, 0);
     evt.Location = dinner.Address;
     evt.Summary = String.Format("{0} with {1}", dinner.Description, dinner.HostedBy);
     evt.AddContact(dinner.ContactPhone);
     evt.Geo = new Geo(dinner.Latitude, dinner.Longitude);
     evt.Url = eventLink;
     evt.Description = eventLink;
     return evt;
 }
        public ActionResult Create(Dinner dinner)
        {
            if (ModelState.IsValid)
            {
                dinner.HostedById = this.nerdIdentity.Name;
                dinner.HostedBy = this.nerdIdentity.FriendlyName;

                RSVP rsvp = new RSVP();
                rsvp.AttendeeNameId = this.nerdIdentity.Name;
                rsvp.AttendeeName = this.nerdIdentity.FriendlyName;

                dinner.RSVPs = new List<RSVP>();
                dinner.RSVPs.Add(rsvp);

                dinnerRepository.InsertOrUpdate(dinner);

                return RedirectToAction("Details", new { id = dinner.DinnerID });
            }

            return View(dinner);
        }
示例#3
0
        private JsonDinner JsonDinnerFromDinner(Dinner dinner)
        {
            return new JsonDinner
            {
                DinnerID = dinner.DinnerID,
                EventDate = dinner.EventDate,
                Latitude = dinner.Latitude,
                Longitude = dinner.Longitude,
                Title = dinner.Title,
                Description = dinner.Description,
                RSVPCount = dinner.RsvpCount.GetValueOrDefault(0),

                //TODO: Need to mock this out for testing...
                //Url = Url.RouteUrl("PrettyDetails", new { Id = dinner.DinnerID } )
                Url = dinner.DinnerID.ToString()
            };
        }
示例#4
0
 public iCalResult(Dinner dinner, string filename)
     : this(filename)
 {
     this.Dinners = new List<Dinner>();
     this.Dinners.Add(dinner);
 }
 private void UpdateDinner(Dinner dinner, DbConnection connection)
 {
     // Future has IsDirtyProperty...
     connection.Execute(@"update Dinners set " +
         "Title = @Title, " +
         "EventDate = @EventDate, " +
         "Description = @Description, " +
         "HostedBy = @HostedBy, " +
         "ContactPhone = @ContactPhone, " +
         "Address = @Address, " +
         "Country = @Country, " +
         "Latitude = @Latitude, " +
         "Longitude = @Longitude, " +
         "HostedById = @HostedById " +
         "WHERE " +
         "DinnerId = @id ",
     new
     {
         id = dinner.DinnerID,
         dinner.Title,
         dinner.EventDate,
         dinner.Description,
         dinner.HostedBy,
         dinner.ContactPhone,
         dinner.Address,
         dinner.Country,
         dinner.Latitude,
         dinner.Longitude,
         dinner.HostedById
     });
 }
 private void InsertOrUpdateDinner(Dinner dinner, DbConnection connection)
 {
     if (dinner.State == ObjectState.Added)
     {
         InsertDinner(dinner, connection);
     }
     else if (dinner.State == ObjectState.Modified)
     {
         UpdateDinner(dinner, connection);
     }
 }
 private void InsertDinner(Dinner dinner, DbConnection connection)
 {
     dinner.DinnerID = connection.Query<int>(@"insert into Dinners " +
         "(Title, EventDate, Description, HostedBy, ContactPhone, Address, Country, Latitude, Longitude, HostedById) " +
         "VALUES (@Title, @EventDate, @Description, @HostedBy, @ContactPhone, @Address, @Country, @Latitude, @Longitude, @HostedById); " +
         "SELECT CAST(scope_identity() as int)",
         new
         {
             dinner.Title,
             dinner.EventDate,
             dinner.Description,
             dinner.HostedBy,
             dinner.ContactPhone,
             dinner.Address,
             dinner.Country,
             dinner.Latitude,
             dinner.Longitude,
             dinner.HostedById
         }).First();
 }
        public void InsertOrUpdate(Dinner dinner)
        {
            // TODO : Need insert / update, need to check rsvp to see if they exist....
            using (var connection = MvcApplication.GetOpenConnection())
            {
                InsertOrUpdateDinner(dinner, connection);

                foreach (var rsvp in dinner.RSVPs)
                {
                    InsertOrUpdateRsvp(rsvp, connection);
                }
            }
        }