Exemplo n.º 1
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.º 2
0
        public static RequirementListingEditView GetRequirementListingEditView(ApplicationDbContext db, Guid listingId, IPrincipal user)
        {
            RequirementListing requirementListing = RequirementListingHelpers.GetRequirementListing(db, listingId);
            AppUser            listingAppUser     = AppUserHelpers.GetAppUser(db, requirementListing.ListingOriginatorAppUserId);
            Branch             listingBranch      = BranchHelpers.GetBranch(db, requirementListing.ListingOriginatorBranchId);
            Company            listingCompany     = CompanyHelpers.GetCompany(db, requirementListing.ListingOriginatorCompanyId);
            Campaign           listingCampaign    = null;
            Guid     campaignId            = Guid.Empty;
            string   campaignName          = "";
            string   campaignStrapline     = "";
            string   campaignDescription   = "";
            DateTime?campaignStartDateTime = null;
            DateTime?campaignEndDateTime   = null;

            ViewButtons buttons = ViewButtonsHelpers.GetAvailableButtonsForSingleView(db, listingAppUser, listingBranch, listingCompany, user);

            if (requirementListing.CampaignId != null)
            {
                if (requirementListing.CampaignId.Value != Guid.Empty)
                {
                    listingCampaign       = CampaignHelpers.GetCampaign(db, requirementListing.CampaignId.Value);
                    campaignId            = listingCampaign.CampaignId;
                    campaignName          = listingCampaign.Name;
                    campaignStrapline     = listingCampaign.StrapLine;
                    campaignDescription   = listingCampaign.Description;
                    campaignStartDateTime = listingCampaign.CampaignStartDateTime;
                    campaignEndDateTime   = listingCampaign.CampaignEndDateTime;
                }
            }

            RequirementListingEditView view = new RequirementListingEditView()
            {
                ListingId           = requirementListing.ListingId,
                ItemDescription     = requirementListing.ItemDescription,
                ItemCategory        = requirementListing.ItemCategory,
                ItemType            = requirementListing.ItemType,
                QuantityRequired    = requirementListing.QuantityRequired,
                QuantityFulfilled   = requirementListing.QuantityFulfilled,
                QuantityOutstanding = requirementListing.QuantityOutstanding,
                UoM                       = requirementListing.UoM,
                RequiredFrom              = requirementListing.RequiredFrom,
                RequiredTo                = requirementListing.RequiredTo,
                AcceptDamagedItems        = requirementListing.AcceptDamagedItems,
                AcceptOutOfDateItems      = requirementListing.AcceptOutOfDateItems,
                CollectionAvailable       = requirementListing.CollectionAvailable,
                ListingStatus             = requirementListing.ListingStatus,
                ListingOriginatorDateTime = requirementListing.ListingOriginatorDateTime,
                ListingAppUser            = listingAppUser,
                ListingBranchDetails      = listingBranch,
                ListingCompanyDetails     = listingCompany,
                SelectedCampaignId        = campaignId,
                CampaignName              = campaignName,
                CampaignStrapLine         = campaignStrapline,
                CampaignDescription       = campaignStrapline,
                CampaignStartDateTime     = campaignStartDateTime,
                CampaignEndDateTime       = campaignEndDateTime,
                Buttons                   = buttons
            };

            return(view);
        }