public ActionResult SubmitRequirementOffer(Guid?listingId, decimal?offerQuantity)
        {
            if (listingId.HasValue && offerQuantity.HasValue)
            {
                if (offerQuantity > 0)
                {
                    RequirementListing requirementListing = RequirementListingHelpers.GetRequirementListing(db, listingId.Value);

                    OfferHelpers.CreateOfferForRequirement(db, User, requirementListing, offerQuantity.Value);
                }

                return(Json(new { success = true }));
            }
            else
            {
                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));
        }