public ActionResult UnsubscribeEmail(string subid)
 {
     try
     {
         M_Subscriber.Unsub(subid);
         return(JavaScript("alert('successfully unsubscribed');"));
     }
     catch (M_CustomException ex)
     {
         ModelState.AddModelError("editsub", ex.message);
         return(RedirectToAction("ViewSubscribers/" + ViewBag.id));
     }
 }
 public ActionResult ImportSubcriber(HttpPostedFileBase UploadFile, SubscribersViewModel model)
 {
     subscriber = new M_Subscriber();
     if (ModelState.IsValid)
     {
         if (UploadFile != null && UploadFile.ContentLength > 0)
         {
             if (UploadFile.FileName.EndsWith(".xlsx"))
             {
                 try
                 {
                     subscriber.ImportExcel(UploadFile, model);
                 }
                 catch (M_CustomException ex)
                 {
                     ModelState.AddModelError("importsub", ex.message);
                     return(RedirectToAction("ImportSubcriber/" + model.ListID));
                 }
             }
             else if (UploadFile.FileName.EndsWith(".xls"))
             {
                 try
                 {
                     subscriber.ImportExcel(UploadFile, model);
                 }
                 catch (M_CustomException ex)
                 {
                     ModelState.AddModelError("importsub", ex.message);
                     return(RedirectToAction("ImportSubcriber/" + model.ListID));
                 }
             }
             else if (UploadFile.FileName.EndsWith(".csv"))
             {
                 try
                 {
                     subscriber.ImportCSV(UploadFile, model);
                 }
                 catch (M_CustomException ex)
                 {
                     ModelState.AddModelError("importsub", ex.message);
                     return(RedirectToAction("ImportSubcriber/" + model.ListID));
                 }
             }
         }
     }
     return(RedirectToAction("ViewSubscribers", model.ListID));
 }
 public ActionResult AddSubcriber(M_Subscriber model)
 {
     userID = GetUser();
     if (model != null)
     {
         try
         {
             model.saveSubscriber(userID);
         }
         catch (M_CustomException ex)
         {
             ModelState.AddModelError("addsub", ex.message);
             return(RedirectToAction("AddSubcriber/" + model.ListID));
         }
     }
     return(RedirectToAction("Index", "List"));
 }
 public ActionResult AddSubcriber(int?id)
 {
     userID     = GetUser();
     list       = new M_List();
     subscriber = new M_Subscriber();
     if (id == null)
     {
         // ViewBag.ListName = new SelectList(dbcontext.NewLists, "ListID", "ListName", "Select List");
         ViewBag.ListName = new SelectList(M_List.GetLists(), "ListID", "ListName", "Select List");
     }
     else
     {
         subscriber.ListID = id;
         return(View(subscriber));
     }
     return(View(subscriber));
 }
        /// <summary>
        /// unsubscribe subscriber from list
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ActionResult Unsubscribers(int?id)
        {
            userID     = GetUser();
            subscriber = new M_Subscriber();
            SubscribersViewModel model = new SubscribersViewModel();

            try
            {
                model.SubscribersToList = subscriber.Unsubscriber(id);
                return(View(model));
            }
            catch (M_CustomException ex)
            {
                ModelState.AddModelError("unsub", ex.message);
                return(RedirectToAction("Index", "List"));
            }
        }
 public ActionResult EditSusbscriber(M_Subscriber model)
 {
     if (model != null)
     {
         try
         {
             model.Update();
             return(RedirectToAction("ViewSubscribers/" + model.ListID));
         }
         catch (M_CustomException ex)
         {
             ModelState.AddModelError("editsub", ex.message);
             return(RedirectToAction("EditSusbscriber/" + model.SubscriberID));
         }
     }
     else
     {
         ModelState.AddModelError("modelnull", "Error while processing request contact administrator");
         return(RedirectToAction("Index"));
     }
 }
 public ActionResult EditSusbscriber(int?id)
 {
     if (id != null)
     {
         M_Subscriber model = new M_Subscriber();
         try
         {
             model = model.Edit(id);
             return(View(model));
         }
         catch (M_CustomException ex)
         {
             ModelState.AddModelError("editsub", ex.message);
             return(RedirectToAction("EditSusbscriber/" + id));
         }
     }
     else
     {
         ModelState.AddModelError("idnull", "Error while processing request contact administrator");
         return(RedirectToAction("Index"));
     }
 }
Пример #8
0
        public ActionResult UnSubscribe(int?SubscriberID)
        {
            M_Subscriber model = new M_Subscriber();
            bool         res;

            if (SubscriberID != null)
            {
                try
                {
                    // res = model.Unsub(SubscriberID);
                    //if (res)
                    //{
                    //    return JavaScript("window.close();");
                    //}
                }
                catch (M_CustomException ex)
                {
                    ModelState.AddModelError("Unsub", ex.message);
                }
            }
            return(JavaScript("window.close()"));
        }
        public ActionResult DeleteSusbscriber(int?id)
        {
            M_Subscriber model = new M_Subscriber();

            if (id != null)
            {
                try
                {
                    model.Delete(id);
                    return(RedirectToAction("Index", "List"));
                }
                catch (M_CustomException ex)
                {
                    ModelState.AddModelError("editsub", ex.message);
                    return(RedirectToAction("ViewSubscribers/" + ViewBag.id));
                }
            }
            else
            {
                ModelState.AddModelError("idnull", "Error while processing request contact administrator");
                return(RedirectToAction("Index", "List"));
            }
        }
        public ActionResult ViewSubscribers(int?id, int?page)
        {
            userID = GetUser();
            const int pageSize   = 30;
            int       pageNumber = (page ?? 1);

            subscriber = new M_Subscriber();
            List <M_Subscriber> subscribersToList = new List <M_Subscriber>();

            if (id != null)
            {
                ViewBag.ListID = id;
                try
                {
                    subscribersToList = subscriber.GetSubscribersbyListID(id);
                    return(View(subscribersToList.ToPagedList(pageNumber, pageSize)));
                }
                catch (M_CustomException ex)
                {
                    ModelState.AddModelError("viewsub", ex.message);
                    return(RedirectToAction("index", "List"));
                }
            }
            else
            {
                try
                {
                    subscribersToList = subscriber.GetAllSubscribers(userID);
                    return(View(subscribersToList.ToPagedList(pageNumber, pageSize)));
                }
                catch (M_CustomException ex)
                {
                    ModelState.AddModelError("viewsub", ex.message);
                    return(RedirectToAction("index", "Home"));
                };
            }
        }