Пример #1
0
        public IHttpActionResult PutInkeyUserQuestion(int id, InkeyUserQuestion inkeyUserQuestion)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != inkeyUserQuestion.InkeyUserQuestionsId)
            {
                return(BadRequest());
            }

            db.Entry(inkeyUserQuestion).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!InkeyUserQuestionExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Пример #2
0
        public async Task<ActionResult> GetMailingLists()
        {
            
            var mailChimpListCollection = await this.manager.Lists.GetAllAsync().ConfigureAwait(false);

            foreach (MailChimp.Net.Models.List lst in mailChimpListCollection)
            {
                var newMailList = new BEMailingList
                {
                    ListName = lst.Name,
                    ListId = lst.Id,
                    MemberCount = lst.Stats.MemberCount,
                    LastUpdated = DateTime.Now                    
                };

                BePreferencesEntities db = new BePreferencesEntities();
                db.BEMailingLists.Add(newMailList);
                db.SaveChanges();
            }

            MailingListsViewModel vwMod = new MailingListsViewModel();

            vwMod.AllLists = mailChimpListCollection;

            return View(vwMod);
        }
Пример #3
0
        private void AddMemberToDatabase(BEMemberList member, string newListId)
        {
            try
            {
                using(var db = new BePreferencesEntities())
                {
                    BEMemberList newMember = new BEMemberList
                    {
                        Email = member.Email,
                        FirstName = member.FirstName,
                        LastName = member.LastName,
                        AccessToken = member.AccessToken,
                        Created = DateTime.Now,
                        ListId = newListId
                    };

                    db.BEMemberLists.Add(newMember);
                    db.SaveChanges();
                    
                }
            }
            catch (Exception)
            {

                throw;
            }
        }
Пример #4
0
        public ActionResult EditProduct(InkeyProduct inkProduct)
        {
            try
            {
                using (var db = new BePreferencesEntities())
                {
                    db.Entry(inkProduct).State = System.Data.Entity.EntityState.Modified;
                    db.SaveChanges();
                }

                return(RedirectToAction("ProductManager"));
            }
            catch (Exception)
            {
                throw;
            }
        }
Пример #5
0
        private void ReInstateMemberToDatabase(BEMemberList member)
        {
            try
            {
                using (var db = new BePreferencesEntities())
                {
                    member.Archived = false;

                    db.Entry(member).State = System.Data.Entity.EntityState.Modified;
                    db.SaveChanges();
                }
            }
            catch (Exception)
            {

                throw;
            }
        }
Пример #6
0
 private void CheckStoresAndAddtoDatabaseUS(List <InkeyStoresU> storesToAdd)
 {
     try
     {
         using (var db = new BePreferencesEntities())
         {
             foreach (InkeyStoresU store in storesToAdd)
             {
                 db.InkeyStoresUS.Add(store);
                 db.SaveChanges();
             }
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Пример #7
0
 private void CheckQuestionsandAddtoDatabase(List <InkeyAnswer> attendeesToAdd)
 {
     try
     {
         using (var db = new BePreferencesEntities())
         {
             foreach (InkeyAnswer question in attendeesToAdd)
             {
                 db.InkeyAnswers.Add(question);
                 db.SaveChanges();
             }
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Пример #8
0
        public ActionResult EditQuestion(InkeyAnswer inkAnswer)
        {
            try
            {
                using (var db = new BePreferencesEntities())
                {
                    inkAnswer.ProductName     = db.InkeyProducts.FirstOrDefault(p => p.InkeyProductsId == inkAnswer.ProductId).ProductName;
                    db.Entry(inkAnswer).State = System.Data.Entity.EntityState.Modified;
                    db.SaveChanges();
                }

                return(RedirectToAction("InkeyAnswerForm"));
            }
            catch (Exception)
            {
                throw;
            }
        }
Пример #9
0
        public ActionResult RemoveProduct(int prodId)
        {
            try
            {
                using (var db = new BePreferencesEntities())
                {
                    InkeyProduct newProd = db.InkeyProducts.FirstOrDefault(p => p.InkeyProductsId == prodId);

                    db.InkeyProducts.Remove(newProd);
                    db.SaveChanges();

                    return(RedirectToAction("ProductManager"));
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Пример #10
0
        public ActionResult AddNewProduct(ProductManagerViewModel newProdMod)
        {
            try
            {
                using (var db = new BePreferencesEntities())
                {
                    InkeyProduct newProd = newProdMod.NewProduct;

                    db.InkeyProducts.Add(newProd);
                    db.SaveChanges();

                    return(RedirectToAction("ProductManager"));
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #11
0
        public ActionResult InkeyAnswerForm(InkeyViewModel inkMod)
        {
            try
            {
                InkeyAnswer newAns = inkMod.answer;
                using (var db = new BePreferencesEntities())
                {
                    newAns.ProductName = db.InkeyProducts.FirstOrDefault(p => p.InkeyProductsId == inkMod.answer.ProductId).ProductName;
                    db.InkeyAnswers.Add(newAns);
                    db.SaveChanges();

                    return(View(new InkeyViewModel()));
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #12
0
        private void RemoveMemberToDatabase(BEMemberList member, string newListId)
        {
            try
            {
                using (var db = new BePreferencesEntities())
                {
                    member.ListId = newListId;
                    member.Archived = true;

                    db.Entry(member).State = System.Data.Entity.EntityState.Modified;
                    db.SaveChanges();

                }
            }
            catch (Exception)
            {

                throw;
            }
        }
Пример #13
0
        public async Task<ActionResult> GenerateMembers()
        {
            IMailChimpManager manager = new MailChimpManager(APIKEY);

            List<BEMemberList> newMemberList = new List<BEMemberList>();

            List<MailChimp.Net.Models.Member> allMembers = new List<MailChimp.Net.Models.Member>();

            var mailChimpListCollection = await manager.Lists.GetAllAsync().ConfigureAwait(false);

            foreach (MailChimp.Net.Models.List lst in mailChimpListCollection)
            {
                var lstMembers = await manager.Members.GetAllAsync(lst.Id).ConfigureAwait(false);

                allMembers.AddRange(lstMembers);
            }

            foreach (MailChimp.Net.Models.Member member in allMembers)
            {
                using (var db = new BePreferencesEntities())
                {
                    var newMember = new BEMemberList
                    {
                        FirstName = member.MergeFields.ContainsKey("FNAME") ? member.MergeFields["FNAME"].ToString() : "NA",
                        LastName = member.MergeFields.ContainsKey("LNAME") ? member.MergeFields["LNAME"].ToString() : "NA",
                        Email = member.EmailAddress,
                        AccessToken = Guid.NewGuid().ToString(),
                        Created = DateTime.Now,
                        ListId = member.ListId
                       

                    };

                    db.BEMemberLists.Add(newMember);
                    db.SaveChanges();
                }
            }

            return View(newMemberList);
        }