//
        // GET: /Meeting/
        public ActionResult New(string description, DateTime? from, DateTime? to)
        {
            using (var container = new MeetingPlannerContainer())
            {
                var newMeeting = new Meeting()
                {
                    Description = description,
                    MeetingStatusId = 1,
                    From = from,
                    To = to,
                };
                container.MeetingSet.Add(newMeeting);
                container.SaveChanges();

                Response.Cookies[MetingOwnerCookie].Value = newMeeting.Id.ToString();
                Response.Cookies[MetingOwnerCookie].Expires = DateTime.Now.AddDays(1);
                return Json(newMeeting.Id);
            }
        }
        public ActionResult SendResults(DateTime[] greenDays, DateTime[] redDays, int meetingId, string userName)
        {
            if (greenDays != null || redDays != null)
            {
                using (var container = new MeetingPlannerContainer())
                {
                    var meeting = container.MeetingSet.First(m => m.Id == meetingId);
                    meeting.RowVersion = Guid.NewGuid();

                    CachedUserName user = null;
                    if (!string.IsNullOrEmpty(userName))
                    {
                        user = ProcessUserName(userName, container);
                    }

                    var voteCookieName = GetVoteCookieName(meetingId);
                    var cookie = Request.Cookies[voteCookieName];
                    if (cookie != null)
                    {
                        DeleteSetBeforeDates(cookie, container);
                    }

                    cookie = new HttpCookie(voteCookieName) { Expires = DateTime.Now.AddDays(1) };
                    var entities = new List<UserMeetingDates>();
                    entities.AddRange(MakeEntityUserMeetingDay(greenDays, meetingId, container, true, user));
                    entities.AddRange(MakeEntityUserMeetingDay(redDays, meetingId, container, false, user));
                    
                    container.SaveChanges();

                    entities.ForEach(e => cookie[e.Id.ToString()] = null);

                    if (Response.Cookies[voteCookieName] != null)
                        Response.Cookies.Remove(voteCookieName);
                    Response.Cookies.Add(cookie);

                    
                }
            }

            return Json(SaveResult.Ok);
        }