Exemplo n.º 1
0
        public static Campaign UpdateCampaignFromCampaignEditView(CampaignEditView view)
        {
            ApplicationDbContext db = new ApplicationDbContext();
            Campaign             campaignDetails = UpdateCampaignFromCampaignEditView(db, view);

            db.Dispose();
            return(campaignDetails);
        }
Exemplo n.º 2
0
        public static CampaignEditView GetCampaignEditView(Guid campaignId, IPrincipal user)
        {
            ApplicationDbContext db = new ApplicationDbContext();

            CampaignEditView view = GetCampaignEditView(db, campaignId, user);

            db.Dispose();
            return(view);
        }
        public IActionResult OnGet(int id)
        {
            var campaign   = _context.Campaigns.Find(id);
            var categories = _context.Categories.ToList();

            CampaignEdit = new CampaignEditView
            {
                Campaign   = campaign,
                Categories = categories
            };
            return(Page());
        }
Exemplo n.º 4
0
        //// GET: Campaigns
        //public ActionResult Index()
        //{
        //    return View(db.Campaigns.ToList());
        //}

        // GET: Campaigns/Details/5
        public ActionResult Details(Guid?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            CampaignEditView campaign = CampaignEditHelpers.GetCampaignEditView(db, id.Value, User);

            if (campaign == null)
            {
                return(HttpNotFound());
            }
            return(View(campaign));
        }
Exemplo n.º 5
0
        // GET: Campaigns/Edit/5
        public ActionResult Edit(Guid?id, bool showHistory)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            CampaignEditView campaign = CampaignEditHelpers.GetCampaignEditView(db, id.Value, User);

            if (campaign == null)
            {
                return(HttpNotFound());
            }

            ViewBag.ShowHistory = showHistory;

            return(View(campaign));
        }
Exemplo n.º 6
0
        public static CampaignEditView GetCampaignEditView(ApplicationDbContext db, Guid campaignId, IPrincipal user)
        {
            Campaign campaignDetails = CampaignHelpers.GetCampaign(db, campaignId);
            AppUser  campaignAppUser = AppUserHelpers.GetAppUser(db, campaignDetails.CampaignOriginatorAppUserId);
            Branch   campaignBranch  = BranchHelpers.GetBranch(db, campaignDetails.CampaignOriginatorBranchId);
            Company  campaignCompany = CompanyHelpers.GetCompany(db, campaignDetails.CampaignOriginatorCompanyId);

            ViewButtons buttons = ViewButtonsHelpers.GetAvailableButtonsForSingleView(db, campaignAppUser, campaignBranch, campaignCompany, user);

            CampaignEditView view = new CampaignEditView()
            {
                CampaignId                 = campaignDetails.CampaignId,
                Name                       = campaignDetails.Name,
                StrapLine                  = campaignDetails.StrapLine,
                Description                = campaignDetails.Description,
                Image                      = campaignDetails.Image,
                ImageLocation              = campaignDetails.ImageLocation,
                Website                    = campaignDetails.Website,
                CampaignStartDateTime      = campaignDetails.CampaignStartDateTime,
                CampaignEndDateTime        = campaignDetails.CampaignEndDateTime,
                LocationName               = campaignDetails.LocationName,
                LocationAddressLine1       = campaignDetails.LocationAddressLine1,
                LocationAddressLine2       = campaignDetails.LocationAddressLine2,
                LocationAddressLine3       = campaignDetails.LocationAddressLine3,
                LocationAddressTownCity    = campaignDetails.LocationAddressTownCity,
                LocationAddressCounty      = campaignDetails.LocationAddressCounty,
                LocationAddressPostcode    = campaignDetails.LocationAddressPostcode,
                LocationTelephoneNumber    = campaignDetails.LocationTelephoneNumber,
                LocationEmail              = campaignDetails.LocationEmail,
                LocationContactName        = campaignDetails.LocationContactName,
                EntityStatus               = campaignDetails.EntityStatus,
                CampaignOriginatorDateTime = campaignDetails.CampaignOriginatorDateTime,
                CampaignAppUser            = campaignAppUser,
                CampaignBranchDetails      = campaignBranch,
                CampaignCompanyDetails     = campaignCompany,
                Buttons                    = buttons
            };

            return(view);
        }
Exemplo n.º 7
0
        public ActionResult Edit([Bind(Include = "CampaignId,Name,StrapLine,Description,Image,ImageLocation,Website,CampaignStartDateTime,CampaignEndDateTime,LocationName,LocationAddressLine1,LocationAddressLine2,LocationAddressLine3,LocationAddressTownCity,LocationAddressCounty,LocationAddressPostcode,LocationTelephoneNumber,LocationEmail,LocationContactName,EntityStatus")] CampaignEditView campaign)
        {
            if (ModelState.IsValid)
            {
                //If the 'Submit' button pressed then update tables, else leave as are so that on reload it takes original values once again.
                if (Request.Form["submitbutton"] != null)
                {
                    //Update tables
                    CampaignHelpers.UpdateCampaignFromCampaignEditView(db, campaign);

                    return(RedirectToAction("Campaigns", "ManageListings"));
                }

                return(RedirectToAction("Edit"));
            }

            //rebuild the missing details before returning to screen to show errors
            Campaign campaignDetails = CampaignHelpers.GetCampaign(db, campaign.CampaignId);

            campaign.CampaignAppUser       = AppUserHelpers.GetAppUser(db, campaignDetails.CampaignOriginatorAppUserId);
            campaign.CampaignBranchDetails = BranchHelpers.GetBranch(db, campaignDetails.CampaignOriginatorBranchId);

            return(View(campaign));
        }
Exemplo n.º 8
0
        public static Campaign UpdateCampaignFromCampaignEditView(ApplicationDbContext db, CampaignEditView view)
        {
            Campaign campaignDetails = GetCampaign(db, view.CampaignId);

            campaignDetails.CampaignId              = view.CampaignId;
            campaignDetails.Name                    = view.Name;
            campaignDetails.StrapLine               = view.StrapLine;
            campaignDetails.Description             = view.Description;
            campaignDetails.Image                   = view.Image;
            campaignDetails.ImageLocation           = view.ImageLocation;
            campaignDetails.Website                 = view.Website;
            campaignDetails.CampaignStartDateTime   = view.CampaignStartDateTime;
            campaignDetails.CampaignEndDateTime     = view.CampaignEndDateTime;
            campaignDetails.LocationName            = view.LocationName;
            campaignDetails.LocationAddressLine1    = view.LocationAddressLine1;
            campaignDetails.LocationAddressLine2    = view.LocationAddressLine2;
            campaignDetails.LocationAddressLine3    = view.LocationAddressLine3;
            campaignDetails.LocationAddressTownCity = view.LocationAddressTownCity;
            campaignDetails.LocationAddressCounty   = view.LocationAddressCounty;
            campaignDetails.LocationAddressPostcode = view.LocationAddressPostcode;
            campaignDetails.LocationTelephoneNumber = view.LocationTelephoneNumber;
            campaignDetails.LocationEmail           = view.LocationEmail;
            campaignDetails.LocationContactName     = view.LocationContactName;
            campaignDetails.EntityStatus            = view.EntityStatus;
            if (view.CampaignOriginatorDateTime != DateTime.MinValue)
            {
                campaignDetails.CampaignOriginatorDateTime = view.CampaignOriginatorDateTime;
            }

            db.Entry(campaignDetails).State = EntityState.Modified;
            db.SaveChanges();

            return(campaignDetails);
        }