Exemplo n.º 1
0
        public ActionResult Edit(Models.CreateEvent ce)
        {
            var test = ce.EventDetails.First().WhoDid;

            Event sevent = db.Events.Where(x => x.ID == ce.ID).Single();

            sevent.EventDetails.ToList().ForEach(m => m.Deleted = true);
            sevent.F******s.ToList().ForEach(m => m.Deleted     = true);

            //return View(ce);
            if (ModelState.IsValid)
            {
                STracker.Event sexevent = db.Events.Where(m => m.ID == ce.ID).Single();

                sexevent.ID            = ce.ID;
                sexevent.Date          = ce.Date;
                sexevent.Notes         = ce.Notes;
                sexevent.OrgamNumber   = ce.OrgamNumber;
                sexevent.OverAllRating = ce.OverAllRating;

                foreach (var item in ce.EventDetails)
                {
                    foreach (var selectedAction in item.SelectedAction)
                    {
                        EventDetail eventDetail = new EventDetail();

                        eventDetail.EventID    = ce.ID;
                        eventDetail.WhoDid     = (int)item.WhoDid;
                        eventDetail.ToWho      = (int)item.ToWho;
                        eventDetail.ActionDone = selectedAction;

                        sevent.EventDetails.Add(eventDetail);
                    }
                }

                if (ce.F***s != null)
                {
                    foreach (var item in ce.F***s)
                    {
                        foreach (var selectedPosition in item.SelectedPosition)
                        {
                            F*****g eventDetail = new F*****g();

                            eventDetail.EventID      = ce.ID;
                            eventDetail.TopPerson    = item.TopPerson;
                            eventDetail.BottomPerson = item.BottomPerson;
                            eventDetail.PoistionID   = selectedPosition;

                            sevent.F******s.Add(eventDetail);
                        }
                    }
                }

                db.SaveChanges();

                return(RedirectToAction("Index"));
            }
            return(View());
        }
Exemplo n.º 2
0
        public ActionResult Create(Models.CreateEvent ce)
        {
            int OwnerID = Convert.ToInt16(Request.Cookies["Stacking"]["ID"]);

            int EventDetailsPeople = ce.EventDetails.Where(m => m.ToWho == 0 || m.WhoDid == 0).Count();


            if (EventDetailsPeople > 0)
            {
                ModelState.AddModelError("ce.EventDetails", "People are missing from the Details");
            }

            if (ce.F***s != null)
            {
                int FuckPeople = ce.F***s.Where(m => m.TopPerson == 0 || m.BottomPerson == 0).Count();
                if (!FuckPeople.Equals(0))
                {
                    ModelState.AddModelError("ce.EventDetails", "People are missing from the F*****g");
                }
            }


            if (ModelState.IsValid)
            {
                STracker.Event stEvent = new Event();

                stEvent.Date          = Convert.ToDateTime(FixFuckenDate(ce.Date.ToString()));
                stEvent.Notes         = ce.Notes;
                stEvent.OrgamNumber   = ce.OrgamNumber;
                stEvent.OverAllRating = ce.OverAllRating;
                stEvent.LoadSize      = ce.LoadSize;
                stEvent.Squirt        = ce.Squirt;
                stEvent.OwnerID       = OwnerID;


                db.Events.Add(stEvent);
                db.Entry(stEvent).State = EntityState.Added;

                foreach (var item in ce.EventDetails)
                {
                    foreach (int EventAction in item.SelectedAction)
                    {
                        EventDetail ed = new EventDetail();

                        ed.WhoDid     = (int)item.WhoDid;
                        ed.ToWho      = (int)item.ToWho;
                        ed.ActionDone = EventAction;

                        stEvent.EventDetails.Add(ed);
                    }
                }

                if (ce.F***s != null)
                {
                    foreach (var f**k in ce.F***s)
                    {
                        if (f**k.SelectedPosition != null)
                        {
                            foreach (int fuckposition in f**k.SelectedPosition)
                            {
                                F*****g f = new F*****g();

                                f.TopPerson    = f**k.TopPerson;
                                f.BottomPerson = f**k.BottomPerson;
                                f.PoistionID   = fuckposition;
                                f.CondomUsed   = f**k.CondomUsed;

                                stEvent.F******s.Add(f);
                            }
                        }
                    }
                }
                if (ce.Locations != null)
                {
                    foreach (var location in ce.Locations)
                    {
                        if (location.SelectedLocations != null)
                        {
                            foreach (int eventlocation in location.SelectedLocations)
                            {
                                EventLocation el = new EventLocation();

                                el.EventID    = ce.ID;
                                el.LocationID = eventlocation;

                                stEvent.EventLocations.Add(el);
                            }
                        }
                    }
                }

                db.SaveChanges();
                ModelState.Clear();

                return(RedirectToAction("Index"));
            }

            List <Person> people = db.People.ToList();

            people.Add(new Person()
            {
                ID = 0, Name = "--Select---"
            });
            ViewBag.People = people.OrderBy(m => m.ID).ToList();

            int currentuserid = Convert.ToInt16(Request.Cookies["Stacking"]["ID"]);

            ViewBag.EventAction = db.EventActions.OrderBy(m => m.Name).Where(m => m.Deleted == false && (m.OwnerID == currentuserid || m.OwnerID == null)).ToList();
            ViewBag.Positions   = db.Positions.OrderBy(m => m.Type).Where(m => m.Deleted == false && (m.OwnerID == currentuserid || m.OwnerID == null)).ToList();
            ViewBag.Locations   = db.Locations.OrderBy(m => m.Name).Where(m => m.Deleted == false && (m.OwnerID == currentuserid || m.OwnerID == null)).ToList();
            ViewBag.OneToTen    = Enumerable.Range(0, 10).Select(i => new SelectListItem {
                Text = i.ToString(), Value = i.ToString()
            });


            ViewBag.SelectedEventAction = ce.EventDetails;

            ViewBag.SelectedPositions = ce.F***s;


            ViewBag.OneToTen = Enumerable.Range(0, 11).Select(i => new SelectListItem {
                Text = i.ToString(), Value = i.ToString()
            });

            return(View(ce));
        }