public ActionResult Create([Bind(Include = "Name,StrapLine,Description,Image,ImageLocation,Website,CampaignStartDateTime,CampaignEndDateTime,LocationName,LocationAddressLine1,LocationAddressLine2,LocationAddressLine3,LocationAddressTownCity,LocationAddressCounty,LocationAddressPostcode,LocationTelephoneNumber,LocationEmail,LocationContactName,CallingAction,CallingController")] CampaignAddView campaign, HttpPostedFileBase file)
        {
            if (ModelState.IsValid)
            {
                if (file != null)
                {
                    string pic  = System.IO.Path.GetFileName(file.FileName);
                    string path = System.IO.Path.Combine(Server.MapPath("~/images"), pic);
                    // file is uploaded
                    //file.SaveAs(path);

                    //campaign.ImageLocation = path;

                    // save the image path path to the database or you can send image
                    // directly to database
                    // in-case if you want to store byte[] ie. for DB
                    using (MemoryStream ms = new MemoryStream())
                    {
                        file.InputStream.CopyTo(ms);
                        byte[] array = ms.GetBuffer();

                        campaign.Image = array;
                    }
                }

                CampaignHelpers.CreateCampaignFromCampaignAddView(campaign, User);

                return(RedirectToAction(campaign.CallingAction, campaign.CallingController));
            }

            return(View(campaign));
        }
Beispiel #2
0
        public ActionResult GetCampaignForHomeCampaignView(Guid campaignId)
        {
            if (campaignId != null)
            {
                Campaign campaignDetails = CampaignHelpers.GetCampaign(campaignId);

                if (campaignDetails != null)
                {
                    return(Json(new { campaignDetails, success = true }));
                }
                return(Json(new { success = false }));
            }
            return(Json(new { success = false }));
        }
        public ActionResult Edit([Bind(Include = "ListingId,ItemDescription,ItemType,QuantityRequired,QuantityFulfilled,QuantityOutstanding,UoM,RequiredFrom,RequiredTo,AcceptDamagedItems,AcceptOutOfDateItems,CollectionAvailable,ListingStatus,SelectedCampaignId,CampaignName,CampaignStrapLine,CampaignDescription,CampaignStartDateTime,CampaignEndDateTime")] RequirementListingEditView requirementListing)
        {
            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
                    RequirementListingHelpers.UpdateRequirementListingFromRequirementListingEditView(db, requirementListing);

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

                return(RedirectToAction("Edit"));
            }

            //rebuild the missing details before returning to screen to show errors
            RequirementListing listing = RequirementListingHelpers.GetRequirementListing(db, requirementListing.ListingId);

            requirementListing.ListingAppUser       = AppUserHelpers.GetAppUser(db, listing.ListingOriginatorAppUserId);
            requirementListing.ListingBranchDetails = BranchHelpers.GetBranch(db, listing.ListingOriginatorAppUserId);

            //Rebuild campaign details as changing will change ID but no address details, so force the change now:
            if (requirementListing.SelectedCampaignId != null)
            {
                Campaign campaign = CampaignHelpers.GetCampaign(db, requirementListing.SelectedCampaignId.Value);
                requirementListing.CampaignName          = campaign.Name;
                requirementListing.CampaignStrapLine     = campaign.StrapLine;
                requirementListing.CampaignDescription   = campaign.Description;
                requirementListing.CampaignStartDateTime = campaign.CampaignStartDateTime;
                requirementListing.CampaignEndDateTime   = campaign.CampaignEndDateTime;
            }

            ViewBag.CampaignList = ControlHelpers.AllActiveCampaignsForUserListDropDown(AppUserHelpers.GetAppUserIdFromUser(User), requirementListing.SelectedCampaignId);

            return(View(requirementListing));
        }
        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));
        }
Beispiel #5
0
        public ActionResult Campaigns()
        {
            List <Campaign> model = CampaignHelpers.GetAllCampaigns();

            return(View(model));
        }