Ejemplo n.º 1
0
        public ActionResult Edit(ObjectId id)
        {
            var model = new SponsorDetail();

            model.Sponsor = Context.Sponsors.GetSponsor(id);

            // first get an active phase
            var phase = Context.Phases.GetActivePhase();

            if (phase != null && phase.PhaseID != ObjectId.Empty)
            {
                // get sponsor information
                model.SponsorInfo = new Count();

                // get all sponsor spots
                model.SponsorInfo.Total = Context.SponsorSpots.GetCountByPhase(phase.PhaseID);

                // get sponsors spots
                model.SponsorInfo.Paid = Context.SponsorSpots.GetSpotsBySponsors(id).Count;

                // get spot information
                model.SpotInfo = new Count();// Context.Spots.GetSpotsInfoByPhase(id);

                var spots = Context.Spots.GetSpotsBySponsor(id);

                model.SpotInfo.Total = spots.Count;
                model.SpotInfo.Paid  = spots.Where(s => s.CustomerId != null && s.CustomerId != ObjectId.Empty).Count();
            }

            ViewBag.Success = false;
            ViewBag.Error   = false;

            return(View(model));
        }
Ejemplo n.º 2
0
        public ActionResult Edit(SponsorDetail model)
        {
            ViewBag.Success = false;
            ViewBag.Error   = true;

            if (ModelState.IsValid)
            {
                bool success = Context.Sponsors.Update(model.Sponsor);

                if (success)
                {
                    ViewBag.Success = true;
                    ViewBag.Error   = false;
                }
            }

            // get spot information
            model.SpotInfo = new Count();// Context.Spots.GetSpotsInfoByPhase(id);

            // get sponsor information
            model.SponsorInfo = new Count();// Context.SponsorSpots.GetSpotsInfoByPhase(id);

            return(View(model));
        }