Example #1
0
        public Shop_New AddNews(Shop_New SN)
        {
            try
            {

                using (shoponlineDataContext context = DbUtils.Create())
                {
                    context.Shop_News.InsertOnSubmit(SN);
                    context.SubmitChanges();
                    return SN;

                }
            }
            catch (Exception)
            {
                return null;
            }
        }
Example #2
0
 public Shop_New UpdateShopNews(Shop_New s_News)
 {
     try
     {
         using (shoponlineDataContext context = DbUtils.Create())
         {
             Shop_New NewsObj = context.Shop_News.Where(u => u.NewsId.Equals(s_News.NewsId)).SingleOrDefault();
             if (NewsObj != null)
             {
                 NewsObj.News_HeadLine = s_News.News_HeadLine;
                 NewsObj.News_Detail = s_News.News_Detail;
                 context.SubmitChanges();
                 return NewsObj;
             }
         }
     }
     catch (Exception)
     {
     }
     return null;
 }
        public ActionResult AddNews(string txtNewsHeadLine, string txtNewsDetail, string hidNewsId)
        {
            try
            {
                if (!String.IsNullOrWhiteSpace(hidNewsId))
                {
                    ViewData[Constants.MENU_PARENT] = Constants.MENU_MANAGE_NEWS;
                    ViewData[Constants.MENU] = Constants.MANAGE_NEWS;
                }
                else
                {
                    ViewData[Constants.MENU_PARENT] = Constants.MENU_MANAGE_NEWS;
                    ViewData[Constants.MENU] = Constants.ADD_NEWS;
                }

                ViewBag.TitleDes = "Free shop advertisement";

                ViewData["txtNewsHeadLine"] = txtNewsHeadLine;
                ViewData["txtNewsDetail"] = txtNewsDetail;
                ViewData["hidNewsId"] = hidNewsId;

                Boolean isValid = true;

                if (string.IsNullOrWhiteSpace(txtNewsHeadLine))
                {
                    ViewData[Constants.OPERATIONALMESSAGE] = Utils.getErrorMessage("Input Field Required", "Please Enter News HeadLine");
                    isValid = false;
                }
                if (string.IsNullOrWhiteSpace(txtNewsDetail))
                {
                    ViewData[Constants.OPERATIONALMESSAGE] = Utils.getErrorMessage("Input Field Required", "Please Enter News Detail");
                    isValid = false;
                }

                if (isValid == true)
                {
                    Shop_New SN = new Shop_New();
                    SN.User_Id = new ShopOnline.Filters.UserSession().getUserSession().UserId;
                    SN.News_HeadLine = txtNewsHeadLine;
                    SN.News_Detail = txtNewsDetail;

                    if (!string.IsNullOrWhiteSpace(hidNewsId))
                    {
                        SN.NewsId = Convert.ToInt64(new SecurityManager().DecodeString(hidNewsId));
                    }
                    if (SN.NewsId > 0)
                    {
                        new Shop_New().UpdateShopNews(SN);
                        return RedirectToRoute(new RouteValueDictionary(new { controller = "ShopNews", action = "ManageShopNews", RecUpdateOperation = "1" }));
                    }
                    else
                    {
                        SN.Created_On = DateTime.UtcNow;
                        Shop_New shop_news = new Shop_New().AddNews(SN);
                        if (shop_news != null)
                        {
                            return RedirectToRoute(new RouteValueDictionary(new { controller = "ShopNews", action = "AddNewsForm", RecSaveOperation = "1" }));
                        }
                        else
                        {
                            ViewData[Constants.OPERATIONALMESSAGE] = Utils.getErrorMessage("Input field required", "Sorry record could not be saved");
                        }
                    }
                }

            }
            catch (Exception ex)
            {

            }
            return View("AddNews");
        }
        public ActionResult AddNewsForm(string RecSaveOperation, string hidNewsId)
        {
            try
            {
                if (!String.IsNullOrWhiteSpace(hidNewsId))
                {
                    ViewData[Constants.MENU_PARENT] = Constants.MENU_MANAGE_NEWS;
                    ViewData[Constants.MENU] = Constants.MANAGE_NEWS;

                    string News_Id = new SecurityManager().DecodeString(hidNewsId);

                    Shop_New SN = new Shop_New().GetShopNews(Convert.ToInt64(News_Id));
                    ViewData["txtNewsHeadLine"] = SN.News_HeadLine;
                    ViewData["txtNewsDetail"] = SN.News_Detail;
                    ViewData["hidNewsId"] = hidNewsId;
                }
                else
                {
                    ViewData[Constants.MENU_PARENT] = Constants.MENU_MANAGE_NEWS;
                    ViewData[Constants.MENU] = Constants.ADD_NEWS;

                    ViewBag.TitleDes = "Free shop advertisement";
                    if (!String.IsNullOrEmpty(RecSaveOperation))
                    {
                        ViewData[Constants.OPERATIONALMESSAGE] = Utils.getSuccessMessage("Success", "Record saved successfully.");
                    }
                }
            }
            catch(Exception ex)
            { }
            return View("AddNews");
        }
 //public ActionResult EditShopNews(string NewsId)
 //{
 //    ViewData[Constants.MENU_PARENT] = Constants.MENU_MANAGE_NEWS;
 //    ViewData[Constants.MENU] = Constants.MANAGE_NEWS;
 //    ViewBag.TitleDes = "Free shop advertisement";
 //    string News_Id = new SecurityManager().DecodeString(NewsId);
 //    ViewData.Model = new Shop_New().GetShopNews(Convert.ToInt64(News_Id));
 //    return View("EditNews");
 //}
 public ActionResult DeleteNews(string NewsId)
 {
     try
     {
         if (!string.IsNullOrEmpty(NewsId))
         {
             string News_Id = new SecurityManager().DecodeString(NewsId);
             Boolean retItem = new Shop_New().DeleteNews(Convert.ToInt64(News_Id));
             if (retItem == true)
             {
                 return RedirectToRoute(new RouteValueDictionary(new { controller = "ShopNews", action = "ManageShopNews", RecDelOperation = "1" }));
             }
             else
             {
                 return RedirectToRoute(new RouteValueDictionary(new { controller = "ShopNews", action = "ManageShopNews", RecDelErrorOperation = "1" }));
             }
         }
     }
     catch (Exception)
     {
     }
     return RedirectToRoute(new RouteValueDictionary(new { controller = "ShopNews", action = "ManageShopNews" }));
 }