/// <summary>
        ///     Load all campaignOwners from the database.
        /// </summary>
        /// <returns></returns>
        private CampaignOwnerSet LoadCampaignOwnerSet()
        {
            var campaignOwnerOwnerSet = new CampaignOwnerSet();

            // Get the collection from the ORM data layer
            var metaData = new LinqMetaData();

            IQueryable <CampaignOwnerEntity> campaignOwners = from c in metaData.CampaignOwner select c;

            var campaignOwnerCollection = ((ILLBLGenProQuery)campaignOwners).Execute <CampaignOwnerCollection>();

            // Fill the entity set from the data collection
            if (campaignOwnerCollection.Count > 0)
            {
                foreach (var campaignOwnerEntity in campaignOwnerCollection)
                {
                    var campaignOwner = new CampaignOwner(campaignOwnerEntity);

                    campaignOwnerOwnerSet.Add(campaignOwner);
                }
            }

            // Return the entity set
            return(campaignOwnerOwnerSet);
        }
        /// <summary>
        ///     Get the current campaignOwner of a campaignOwner. The cache is not bypassed by default.
        /// </summary>
        /// <param name="campaignOwnerId">The campaignOwner identifier</param>
        /// <param name="noCache">Bypass the cache</param>
        /// <param name="refreshCache">Force refresh the cache</param>
        /// <returns>A campaignOwner</returns>
        public CampaignOwner GetCampaignOwner(int campaignOwnerId, bool noCache, bool refreshCache)
        {
            // If no cache the load and return a entity from the database
            if (noCache && !refreshCache)
            {
                return(LoadCampaignOwner(campaignOwnerId));
            }

            CampaignOwner campaignOwner;

            string cacheKey = CampaignOwner.GetCacheKeyById(campaignOwnerId);

            if (!CacheManagerProvider.GetCacheManagerInstance().Contains <CampaignOwner>(cacheKey) || refreshCache)
            {
                // Load the entity from the database
                campaignOwner = LoadCampaignOwner(campaignOwnerId);

                if (campaignOwner != null)
                {
                    // Add the entity to the cache by reading caching parameters from the configuration
                    CacheManagerProvider.GetCacheManagerInstance().Insert(cacheKey, campaignOwner,
                                                                          ConfigurationManager.GetCacheExpirationByType(
                                                                              campaignOwner.GetType()));
                }
            }
            else
            {
                campaignOwner = CacheManagerProvider.GetCacheManagerInstance().Get <CampaignOwner>(cacheKey);
            }

            return(campaignOwner);
        }
Beispiel #3
0
        public ActionResult DeleteConfirmed(int id)
        {
            CampaignOwner campaignOwner = db.CampaignOwners.Find(id);

            db.CampaignOwners.Remove(campaignOwner);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        /// <summary>
        /// Create a new campaignOwner object and persist it into the database.
        /// </summary>
        /// <param name="campaignOwner">The campaignOwner object</param>
        public CampaignOwner AddCampaignOwner(CampaignOwner campaignOwner)
        {
            // Persist the object into the database
            campaignOwner.Save();

            // Return the new object with the new identifier (AUTO)
            return(campaignOwner);
        }
 public ActionResult Edit([Bind(Include = "ID,FirstName,LastName,Email,Phone")] CampaignOwner campaignOwner)
 {
     if (ModelState.IsValid)
     {
         db.Entry(campaignOwner).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(campaignOwner));
 }
Beispiel #6
0
 public ActionResult Edit([Bind(Include = "ID,TradeID,Name,Role,Email,Phone")] CampaignOwner campaignOwner)
 {
     if (ModelState.IsValid)
     {
         db.Entry(campaignOwner).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.TradeID = new SelectList(db.Trades, "ID", "Name", campaignOwner.TradeID);
     return(View(campaignOwner));
 }
        public ActionResult Create([Bind(Include = "ID,FirstName,LastName,Email,Phone")] CampaignOwner campaignOwner)
        {
            if (ModelState.IsValid)
            {
                db.CampaignOwners.Add(campaignOwner);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(campaignOwner));
        }
Beispiel #8
0
        // GET: CampaignOwners/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            CampaignOwner campaignOwner = db.CampaignOwners.Find(id);

            if (campaignOwner == null)
            {
                return(HttpNotFound());
            }
            return(View(campaignOwner));
        }
Beispiel #9
0
        // GET: CampaignOwners/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            CampaignOwner campaignOwner = db.CampaignOwners.Find(id);

            if (campaignOwner == null)
            {
                return(HttpNotFound());
            }
            ViewBag.TradeID = new SelectList(db.Trades, "ID", "Name", campaignOwner.TradeID);
            return(View(campaignOwner));
        }
Beispiel #10
0
 /// <summary>
 /// Delete a campaignOwner object and persist changes into the database
 /// </summary>
 /// <param name="campaignOwner"></param>
 public void DeleteCampaignOwner(CampaignOwner campaignOwner)
 {
     // Remove the object into the database
     campaignOwner.Delete();
 }
Beispiel #11
0
 /// <summary>
 /// Update a campaignOwner object and persist changes into the database
 /// </summary>
 /// <param name="campaignOwner"></param>
 public void UpdateCampaignOwner(CampaignOwner campaignOwner)
 {
     // Persist the object into the database
     campaignOwner.Save();
 }
Beispiel #12
0
        /// <summary>
        ///     Load a campaignOwner from the database given its Id.
        /// </summary>
        /// <returns></returns>
        private CampaignOwner LoadCampaignOwner(int campaignOwnerId)
        {
            var campaignOwner = new CampaignOwner(new CampaignOwnerEntity(campaignOwnerId));

            return(campaignOwner);
        }