コード例 #1
0
        public ActionResult PartnershipNightEdit(int partnershipNightId)
        {
            TempData["Title"] = "Edit";

            // Get the correct partnership night, and create a view model to store values in
            PartnershipNight   pnight = pnRepo.GetPartnershipNightById(partnershipNightId);
            PartnershipNightVM temp   = new PartnershipNightVM()
            {
                AfterTheEventFinished  = pnight.AfterTheEventFinished,
                BeforeTheEventFinished = pnight.BeforeTheEventFinished,
                CheckRequestFinished   = pnight.CheckRequestFinished,
                BVLocation             = pnight.BVLocation,
                Charity            = pnight.Charity,
                StartDate          = pnight.StartDate,
                EndDate            = pnight.EndDate,
                Comments           = pnight.Comments,
                CheckRequestId     = pnight.CheckRequestId,
                PartnershipNightId = pnight.PartnershipNightId
            };

            temp.BvLocations = lRepo.GetBvLocations().ToList <BvLocation>();
            temp.Charities   = charRepo.GetCharities().ToList <Charity>();

            //PNightEditViewModel vModel = new PNightEditViewModel();

            ////Set view model to corresponding partnership night values
            //vModel.PartnershipNight = pnight;

            //Set List variables to contain lists of child objects for selection in the view
            //vModel.Charities = charRepo.GetCharities().ToList<Charity>();
            //vModel.Locations = lRepo.GetBvLocations().ToList<BvLocation>();

            return(View(temp));
        }
コード例 #2
0
        public ActionResult PartnershipNightEdit(PNightEditViewModel pn)
        {
            var pnEvent = new PartnershipNight();

            if (pn.PartnershipNight.PartnershipNightId != 0)
            {
                pnEvent.PartnershipNightId = pn.PartnershipNight.PartnershipNightId;
            }
            pnEvent.EndDate                = pn.PartnershipNight.EndDate;
            pnEvent.StartDate              = pn.PartnershipNight.StartDate;
            pnEvent.AfterTheEventFinished  = pn.PartnershipNight.AfterTheEventFinished;
            pnEvent.BeforeTheEventFinished = pn.PartnershipNight.BeforeTheEventFinished;
            pnEvent.CheckRequestFinished   = pn.PartnershipNight.CheckRequestFinished;
            pnEvent.CheckRequestId         = pn.PartnershipNight.CheckRequestId;
            pnEvent.Comments               = pn.PartnershipNight.Comments;
            pnEvent.BVLocation             = lRepo.GetBvLocation(pn.PartnershipNight.BVLocation.BvLocationId);
            pnEvent.Charity                = charRepo.GetCharityById(pn.PartnershipNight.Charity.CharityId);

            if (pnEvent != null && pnEvent.BVLocation != null && pnEvent.Charity != null)
            {
                pnRepo.UpdatePartnershipNight(pnEvent);
                TempData["message"] = string.Format("Event for {0} has been saved", pn.PartnershipNight.Charity.Name);
                return(RedirectToAction("PartnershipNightIndex"));
            }
            else
            {
                return(View());
            }
        }
コード例 #3
0
        /*
         * public IQueryable<PartnershipNight> GetPartnershipNightsByMonth(DateTime extractMonthAndYear)
         * {
         *  throw new NotImplementedException();
         * }
         *
         * public IQueryable<PartnershipNight> GetPartnershipNightsByDate(DateTime date)
         * {
         *  throw new NotImplementedException();
         * }
         *
         * public IQueryable<PartnershipNight> GetPartnershipNightsByLoc(BvLocation loc)
         * {
         *  throw new NotImplementedException();
         * }
         *
         * public IQueryable<PartnershipNight> GetPartnershipNightsByDateRange(DateTime firstDate, DateTime lastDate, BvLocation loc)
         * {
         *  throw new NotImplementedException();
         * }
         */
        public void UpdatePartnershipNight(PartnershipNight pn)
        {
            var db = new CapstoneDbContext();

            if (pn.PartnershipNightId == 0)
            {
                pn.Charity    = db.Charities.Find(pn.Charity.CharityId);
                pn.BVLocation = db.BvLocations.Find(pn.BVLocation.BvLocationId);
                db.PartnershipNights.Add(pn);
            }
            else
            {
                var dbEntry = db.PartnershipNights.Find(pn.PartnershipNightId);
                if (dbEntry != null)
                {
                    dbEntry.Date                   = pn.Date;
                    dbEntry.Charity                = pn.Charity;
                    dbEntry.BVLocation             = pn.BVLocation;
                    dbEntry.CheckRequestId         = pn.CheckRequestId;
                    dbEntry.Comments               = pn.Comments;
                    dbEntry.CheckRequestFinished   = pn.CheckRequestFinished;
                    dbEntry.BeforeTheEventFinished = pn.BeforeTheEventFinished;
                    dbEntry.AfterTheEventFinished  = pn.AfterTheEventFinished;
                }
            }
            db.SaveChanges();
        }
コード例 #4
0
        public void UpdatePartnershipNight(PartnershipNightVM pn)
        {
            var db = new ApplicationDbContext();

            if (pn.PartnershipNightId == 0)
            {
                db.PartnershipNights.Add(new PartnershipNight()
                {
                    StartDate  = pn.StartDate,
                    EndDate    = pn.EndDate,
                    Comments   = pn.Comments,
                    Charity    = db.Charities.Find(pn.Charity.CharityId),
                    BVLocation = db.BvLocations.Find(pn.BVLocation.BvLocationId)
                });
            }
            else
            {
                PartnershipNight dbEntry = db.PartnershipNights.Find(pn.PartnershipNightId);
                if (dbEntry != null)
                {
                    dbEntry.StartDate  = pn.StartDate;
                    dbEntry.EndDate    = pn.EndDate;
                    dbEntry.Comments   = pn.Comments;
                    dbEntry.Charity    = db.Charities.Find(pn.Charity.CharityId);
                    dbEntry.BVLocation = db.BvLocations.Find(pn.BVLocation.BvLocationId);
                }
            }
            db.SaveChanges();
        }
コード例 #5
0
        public ActionResult Edit(PNightEditViewModel vmodel)
        {
            //PartnershipNight pnight = pnRepo.GetPartnershipNights().FirstOrDefault<PartnershipNight>(pn => pn.PartnershipNightId)

            if (ModelState.IsValid)
            {
                // Transfer view model values to a partnership night object
                PartnershipNight pnight = new PartnershipNight();
                pnight.PartnershipNightId = vmodel.PartnershipNightId;
                pnight.Date                   = vmodel.Date;
                pnight.Comments               = vmodel.Comments;
                pnight.CheckRequestId         = vmodel.CheckRequestId;
                pnight.CheckRequestFinished   = vmodel.CheckRequestFinished;
                pnight.BeforeTheEventFinished = vmodel.BeforeTheEventFinished;
                pnight.AfterTheEventFinished  = vmodel.AfterTheEventFinished;

                // Store the correct child objects
                pnight.Charity    = charRepo.GetCharities().FirstOrDefault(ch => ch.CharityId == vmodel.CharityId);
                pnight.BVLocation = bvlocRepo.GetBvLocations().FirstOrDefault(bvl => bvl.BvLocationId == vmodel.BVLocationId);

                // Save the changes to the partnership night
                pnRepo.UpdatePartnershipNight(pnight);
                TempData["message"] = string.Format("Partnership Night for BV Location {0}, {1} has been saved", pnight.Date.ToShortDateString(), pnight.BVLocation.BvStoreNum);
                return(RedirectToAction("Index"));
            }
            else
            {
                // there is something wrong with the data values
                return(View(vmodel));
            }
        }
コード例 #6
0
        public ActionResult Edit(int partnershipNightId)
        {
            // Get the correct partnership night, and create a view model to store values in
            PartnershipNight    pnight = pnRepo.GetPartnershipNights().FirstOrDefault(pn => pn.PartnershipNightId == partnershipNightId);
            PNightEditViewModel vmodel = new PNightEditViewModel();

            //Set view model to corresponding partnership night values
            vmodel.PartnershipNightId = pnight.PartnershipNightId;
            vmodel.Date                   = pnight.Date;
            vmodel.CharityId              = pnight.Charity.CharityId;
            vmodel.BVLocationId           = pnight.BVLocation.BvLocationId;
            vmodel.CheckRequestId         = pnight.CheckRequestId;
            vmodel.Comments               = pnight.Comments;
            vmodel.CheckRequestFinished   = pnight.CheckRequestFinished;
            vmodel.BeforeTheEventFinished = pnight.BeforeTheEventFinished;
            vmodel.AfterTheEventFinished  = pnight.AfterTheEventFinished;

            //Set List variables to contain lists of child objects for selection in the view
            vmodel.Charities = charRepo.GetCharities().ToList <Charity>();
            vmodel.Locations = bvlocRepo.GetBvLocations().ToList <BvLocation>();

            //Set session variables to contain lists of child objects for selection in the view
            //Session["charities"] = charRepo.GetCharities().ToList<Charity>();
            //Session["bvlocations"] = bvlocRepo.GetBvLocations().ToList<BvLocation>();

            return(View(vmodel));
        }
コード例 #7
0
        public void UpdateEvent(int id, string NewEventStart, string NewEventEnd)
        {
            //find the pn with the id
            PartnershipNight pn = pnRepo.GetPartnershipNightById(id);

            pn.StartDate = DateTime.Parse(NewEventStart);
            pn.EndDate   = DateTime.Parse(NewEventEnd);
            pnRepo.UpdatePartnershipNight(pn);
        }
コード例 #8
0
        public void AddPartnershipNight(PartnershipNight pn)
        {
            //throw new NotImplementedException();
            var db = new CapstoneDbContext();

            db.PartnershipNights.Add(pn);
            db.SaveChanges();
            //TODO: Add in error handling
        }
コード例 #9
0
        public ActionResult PartnershipNightDelete(int partnershipNightId)
        {
            PartnershipNight deletedPNight = pnRepo.DeletePartnershipNight(partnershipNightId);

            if (deletedPNight != null)
            {
                TempData["message"] = string.Format("Event on {0} was deleted", deletedPNight.StartDate.ToShortDateString());
            }
            return(RedirectToAction("PartnershipNightIndex"));
        }
コード例 #10
0
        public ActionResult PartnershipNightEdit(int partnershipNightId)
        {
            TempData["Title"] = "Edit";

            // Get the correct partnership night, and create a view model to store values in
            PartnershipNight    pnight = pnRepo.GetPartnershipNightById(partnershipNightId);
            PNightEditViewModel temp   = new PNightEditViewModel();

            temp.PartnershipNight = pnight;
            temp.Locations        = lRepo.GetBvLocations().ToList <BvLocation>();
            temp.Charities        = charRepo.GetCharities().ToList <Charity>();

            return(View(temp));
        }
コード例 #11
0
        public PartnershipNight DeletePartnershipNight(int id) //should this take a partnership night or id as parameter?
        {
            //throw new NotImplementedException();
            var db = new CapstoneDbContext();
            PartnershipNight dbEntry = db.PartnershipNights.Find(id);

            if (dbEntry != null)
            {
                db.PartnershipNights.Remove(dbEntry);
                db.SaveChanges();
            }
            return(dbEntry);
            //TODO: Add in error handling
        }
コード例 #12
0
 //TODO:  need use event props to create pnight props and save that to db
 public bool CreateNewEvent(string Title, int id, string NewStartDate, string NewStartTime, string NewEndDt, string NewEndTime)
 {
     try
     {
         var db = new ApplicationDbContext();
         PartnershipNight rec = new PartnershipNight();
         rec.Charity    = db.Charities.Find(Title);
         rec.BVLocation = db.BvLocations.Find(id);
         rec.StartDate  = DateTime.ParseExact(NewStartDate + " " + NewStartTime, "MM/dd/yyyy HH:mm tt", CultureInfo.InvariantCulture);
         rec.EndDate    = DateTime.ParseExact(NewEndDt + " " + NewEndTime, "MM/dd/yyyy H:mm tt", CultureInfo.InvariantCulture);
         db.PartnershipNights.Add(rec);
         db.SaveChanges();
     }
     catch (Exception)
     {
         return(false);
     }
     return(true);
 }