Ejemplo n.º 1
0
        public ActionResult Delete(int Id)
        {
            try
            {
                FeedBusinessLayer _feedBusLayer = new FeedBusinessLayer();
                string            fileName      = _feedBusLayer.DeleteImage(Id);
                var path = Path.Combine(Server.MapPath("~/img"), fileName);


                if ((System.IO.File.Exists(path)))
                {
                    System.IO.File.Delete(path);
                }


                _feedBusLayer.DeleteFeed(Id);
                return(RedirectToAction("ManageFeed", "Home"));
            }

            catch (Exception ex)
            {
                TempData["AlertMessage"] = "Error";
                string Module_name             = "ManageFeed";
                string Action                  = "ManageFeed_Delete";
                ErrorExceptionHandler _handler = new ErrorExceptionHandler();
                _handler.ReportError(Module_name, ex.Message, Action);
                return(RedirectToAction("index", "Exception"));
            }
        }
        public void Mailer(int FeedId)
        {
            ErrorExceptionHandler _handler = new ErrorExceptionHandler();

            _handler.Webservice_initialize("Web service initialized for subscribers");
            try
            {
                var path = Path.Combine(Server.MapPath("~/WebService"), "MailContent.html");

                string html            = File.ReadAllText(path);
                string Email_Subscribe = "";
                Feed   _feed           = new Feed();

                string connectionString = ConfigurationManager.ConnectionStrings[ConnectionName].ConnectionString;

                using (SqlConnection con = new SqlConnection(connectionString))
                {
                    con.Open();
                    SqlCommand cmd = new SqlCommand("select TOP 1 * from GS_FEED WHERE Rowstatus='A'  order by 1 desc", con);
                    cmd.CommandType = CommandType.Text;

                    SqlDataReader rdr = cmd.ExecuteReader();
                    while (rdr.Read())
                    {
                        _feed.ID          = (int)rdr["FeedID"];
                        _feed.Title       = rdr["Title"].ToString();
                        _feed.Description = rdr["Description"].ToString();
                        _feed.image       = rdr["Images"].ToString();
                        _feed.link        = rdr["link"].ToString();
                        _feed.CategoryID  = (int)rdr["Category_Id"];
                        _feed.Rowstatus   = Convert.ToChar(rdr["Rowstatus"]);
                    }
                }

                html = html.Replace("Title", _feed.Title);
                html = html.Replace("Description", _feed.Description);
                html = html.Replace("link", _feed.link);
                html = html.Replace("PicName", _feed.image);



                List <Subscribers> _Subscribers = GetSubscribers.ToList();

                for (int i = 0; i < _Subscribers.Count; i++)
                {
                    Email_Subscribe = _Subscribers[i].Email;
                    Sentmail(html, Email_Subscribe, _feed.Title);
                }

                JavaScriptSerializer js = new JavaScriptSerializer();
                Context.Response.Write(js.Serialize(_Subscribers));
            }

            catch (Exception ex)
            {
                string Module_name = "MailerWebservice";
                string Action      = "Get_All_Subscribers";
                _handler.ReportError(Module_name, ex.Message, Action);
            }
        }
Ejemplo n.º 3
0
 private void readChar()
 {
     readTillNextChar('\'');
     if (ct.Length != 1)
     {
         ErrorExceptionHandler.Throw(LexerException.InvalidToken("Can only store one char", ct, lc));
     }
 }
Ejemplo n.º 4
0
        public ActionResult ManageFeed(string search, int?page, int?categoryId)
        {
            try
            {
                //CategoryBusinessLayer CatBussLayer = new CategoryBusinessLayer();
                //ViewBag.Categories = new SelectList(CatBussLayer.Get_Category, "Category_Id", "Category_Name");

                ViewBag.SelectedItem = categoryId;
                CategoryBusinessLayer CatBussLayer = new CategoryBusinessLayer();
                ViewBag.Categories = new SelectList(CatBussLayer.Get_Category(), "Category_Id", "Category_Name", "2");

                //FeedBusinessLayer feedBusLayer = new FeedBusinessLayer();
                //List<Feed> _feeds = feedBusLayer.GetEditFeeds.ToList();

                //return View(_feeds.ToList());

                if (categoryId != null)
                {
                    if (categoryId == 1)
                    {
                        FeedBusinessLayer FeedBusLayer = new FeedBusinessLayer();
                        List <Feed>       feeds        = FeedBusLayer.GetEditFeeds.ToList();
                        return(View(feeds.ToList().ToPagedList(page ?? 1, 8)));
                    }
                    else
                    {
                        FeedBusinessLayer FeedBusLayer = new FeedBusinessLayer();
                        List <Feed>       feeds        = FeedBusLayer.GetEditFeeds.ToList();
                        return(View(feeds.Where(x => x.CategoryID == categoryId).ToList().ToPagedList(page ?? 1, 15)));
                    }
                }

                else if (search == null)
                {
                    FeedBusinessLayer FeedBusLayer = new FeedBusinessLayer();
                    List <Feed>       feeds        = FeedBusLayer.GetEditFeeds.ToList();
                    return(View(feeds.ToList().ToPagedList(page ?? 1, 8)));
                }

                else
                {
                    FeedBusinessLayer FeedBusLayer = new FeedBusinessLayer();
                    List <Feed>       feeds        = FeedBusLayer.GetEditFeeds.ToList();
                    //return View(feeds.Where(x => x.Title.StartsWith(search)).ToList().ToPagedList(page ??5,1));
                    return(View(feeds.Where(x => x.Title.ToLowerInvariant().Contains(search) || search == null).ToList().ToPagedList(page ?? 1, 15)));
                }
            }

            catch (Exception ex)
            {
                TempData["AlertMessage"] = "Error";
                string Module_name             = "ManageFeed";
                string Action                  = "ManageFeed_GetAllFeeds_index";
                ErrorExceptionHandler _handler = new ErrorExceptionHandler();
                _handler.ReportError(Module_name, ex.Message, Action);
                return(RedirectToAction("index", "Exception"));
            }
        }
Ejemplo n.º 5
0
        public ActionResult Index(string search, int?page, int?categoryId)
        {
            try
            {
                ViewBag.SelectedItem = categoryId;
                CategoryBusinessLayer CatBussLayer = new CategoryBusinessLayer();
                ViewBag.Categories = new SelectList(CatBussLayer.Get_Category(), "Category_Id", "Category_Name", "2");


                if (categoryId != null)
                {
                    if (categoryId == 1)
                    {
                        FeedBusinessLayer FeedBusLayer = new FeedBusinessLayer();
                        List <Feed>       feeds        = FeedBusLayer.Feeds.ToList();
                        return(View(feeds.ToList().ToPagedList(page ?? 1, 15)));
                    }
                    else
                    {
                        FeedBusinessLayer FeedBusLayer = new FeedBusinessLayer();
                        List <Feed>       feeds        = FeedBusLayer.Feeds.ToList();
                        return(View(feeds.Where(x => x.CategoryID == categoryId).ToList().ToPagedList(page ?? 1, 15)));
                    }
                }

                else if (search == null)
                {
                    FeedBusinessLayer FeedBusLayer = new FeedBusinessLayer();
                    List <Feed>       feeds        = FeedBusLayer.Feeds.ToList();
                    return(View(feeds.ToList().ToPagedList(page ?? 1, 15)));
                }

                else
                {
                    FeedBusinessLayer FeedBusLayer = new FeedBusinessLayer();
                    List <Feed>       feeds        = FeedBusLayer.Feeds.ToList();
                    //return View(feeds.Where(x => x.Title.StartsWith(search)).ToList().ToPagedList(page ??5,1));
                    return(View(feeds.Where(x => x.Title.ToLowerInvariant().Contains(search.ToLower()) || search == null).ToList().ToPagedList(page ?? 1, 15)));
                }
            }


            catch (Exception ex)
            {
                string Module_name             = "Home_index";
                string Action                  = "Read all post";
                ErrorExceptionHandler _handler = new ErrorExceptionHandler();
                _handler.ReportError(Module_name, ex.Message, Action);
                return(RedirectToAction("index", "Exception"));
            }
        }
Ejemplo n.º 6
0
        public ActionResult Save()
        {
            Feed feed_cs = new Feed();

            TryUpdateModel(feed_cs);

            //feed_cs.CategoryID = 1;   //We are manually setting Cate ID ,hidden in html

            //if (ModelState.IsValid)
            try
            {
                if (feed_cs.File != null)
                {
                    if (feed_cs.File.ContentLength > 0)
                    {
                        var fileName = Path.GetFileName(feed_cs.File.FileName);

                        var path = Path.Combine(Server.MapPath("~/img"), fileName);
                        feed_cs.File.SaveAs(path);
                        feed_cs.image = fileName;
                    }
                    else
                    {
                        feed_cs.image = "NIL";
                    }
                }
                else
                {
                    feed_cs.image = "NIL";
                }


                FeedBusinessLayer feedBusLayer = new FeedBusinessLayer();
                feedBusLayer.AddFeed(feed_cs);



                TempData["AlertMessage"] = "Hai this is working";
                return(RedirectToAction("create"));
            }
            catch (Exception ex)
            {
                TempData["AlertMessage"] = "Error";
                string Module_name             = "Home_Create";
                string Action                  = "Create new post";
                ErrorExceptionHandler _handler = new ErrorExceptionHandler();
                _handler.ReportError(Module_name, ex.Message, Action);
                return(RedirectToAction("index", "Exception"));
            }
        }
Ejemplo n.º 7
0
 public ActionResult Create()
 {
     try
     {
         CategoryBusinessLayer CatBussLayer = new CategoryBusinessLayer();
         ViewBag.Categories = new SelectList(CatBussLayer.Get_Category(), "Category_Id", "Category_Name");
         return(View());
     }
     catch (Exception ex)
     {
         string Module_name             = "Create";
         string Action                  = "Create_Get Request";
         ErrorExceptionHandler _handler = new ErrorExceptionHandler();
         _handler.ReportError(Module_name, ex.Message, Action);
         return(RedirectToAction("index", "Exception"));
     }
 }
Ejemplo n.º 8
0
        public ActionResult Update(Feed _Feed)
        {
            FeedBusinessLayer _feedBusLayer = new FeedBusinessLayer();

            TryUpdateModel(_Feed);
            // _Feed.CategoryID = 1;//we are maually setting CategoryID
            //if (ModelState.IsValid)
            try
            {
                if (_Feed.File != null)
                {
                    if (_Feed.File.ContentLength > 0)
                    {
                        var fileName = Path.GetFileName(_Feed.File.FileName);

                        var path = Path.Combine(Server.MapPath("~/img"), fileName);
                        _Feed.File.SaveAs(path);
                        _Feed.image = fileName;
                    }
                }

                else if (_Feed.image == null)
                {
                    _Feed.image = "NIL";
                }

                _feedBusLayer.UpdateFeed(_Feed);
                TempData["AlertMessage"] = "Hai this is working";
                return(RedirectToAction("ManageFeed", "Home"));
            }

            catch (Exception ex)
            {
                TempData["AlertMessage"] = "Error";
                string Module_name             = "ManageFeed_Update";
                string Action                  = "Save";
                ErrorExceptionHandler _handler = new ErrorExceptionHandler();
                _handler.ReportError(Module_name, ex.Message, Action);
                return(RedirectToAction("index", "Exception"));
            }



            //return RedirectToAction("ManageFeed", "Home");
        }
        private void Sentmail(string html, string Email_Subscribe, string Subject)
        {
            try
            {
                string smtpAddress = "smtpout.secureserver.net";
                int    portNumber  = 80;
                //bool enableSSL = true;

                string emailFrom = "*****@*****.**";
                string password  = "******";
                string emailTo   = Email_Subscribe;
                string subject   = Subject;
                string body      = html;

                using (MailMessage mail = new MailMessage())
                {
                    mail.From = new MailAddress(emailFrom, "Maximum Referral");
                    mail.To.Add(emailTo);
                    mail.Subject    = subject;
                    mail.Body       = body;
                    mail.IsBodyHtml = true;
                    // Can set to false, if you are sending pure text.

                    //mail.Attachments.Add(new Attachment("C:\\SomeFile.txt"));
                    //mail.Attachments.Add(new Attachment("C:\\SomeZip.zip"));

                    using (SmtpClient smtp = new SmtpClient(smtpAddress, portNumber))
                    {
                        smtp.Credentials = new NetworkCredential("*****@*****.**", password);
                        smtp.Send(mail);
                    }
                }
            }


            catch (Exception ex)
            {
                string Module_name             = "MailerWebservice";
                string Action                  = "Email_sent";
                ErrorExceptionHandler _handler = new ErrorExceptionHandler();
                _handler.ReportError(Module_name, ex.Message, Action);
            }
        }
Ejemplo n.º 10
0
        [HttpGet]//when press edit button
        public ActionResult Edit(int Id)
        {
            try
            {
                FeedBusinessLayer _feedBusLayer = new FeedBusinessLayer();
                Feed _feed = _feedBusLayer.GetEditFeeds.Single(fd => fd.ID == Id);
                return(View(_feed));
            }



            catch (Exception ex)
            {
                TempData["AlertMessage"] = "Error";
                string Module_name             = "ManageFeed_Edit";
                string Action                  = "Get";
                ErrorExceptionHandler _handler = new ErrorExceptionHandler();
                _handler.ReportError(Module_name, ex.Message, Action);
                return(RedirectToAction("index", "Exception"));
            }
        }