예제 #1
0
        public void AddSocialMedias(SocialMediasModel _SocialMediasModel)
        {
            _SocialMediasModel.SocialMediaID = (short)((int)(from S in SocialMediasData.Descendants("SocialMedia") orderby(short) S.Element("SocialMediaID") descending select(short) S.Element("SocialMediaID")).FirstOrDefault() + 1);
            SocialMediasData.Root.Add(new XElement("SocialMedia", new XElement("SocialMediaID", _SocialMediasModel.SocialMediaID),
                                                   new XElement("SocialMediaNameTxt", _SocialMediasModel.SocialMediaNameTxt)));

            SocialMediasData.Save(HttpContext.Current.Server.MapPath("~/App_Data/SocialMedia.xml"));
        }
예제 #2
0
        public void EditSocialMedias(SocialMediasModel _SocialMediasModel)
        {
            try
            {
                XElement node = SocialMediasData.Root.Elements("SocialMedia").Where(i => (int)i.Element("SocialMediaID") == _SocialMediasModel.SocialMediaID).FirstOrDefault();

                node.SetElementValue("SocialMediaNameTxt", _SocialMediasModel.SocialMediaNameTxt);
                SocialMediasData.Save(HttpContext.Current.Server.MapPath("~/App_Data/SocialMedia.xml"));
            }
            catch (Exception)
            {
                throw new NotImplementedException();
            }
        }
예제 #3
0
        public ActionResult CreateSocialMedias(int?SocialMediasid)
        {
            var _SocialMediasContext = new Contexts.SocialMediasContexts();
            var _SocialMediasModel   = new SocialMediasModel();

            ViewBag.Title  = (SocialMediasid.HasValue ? "Edit " : "Add ") + " Social Medias Details ";
            ViewBag.Submit = SocialMediasid.HasValue && SocialMediasid.Value > 0 ? "Update" : "Save";
            if (SocialMediasid.HasValue && SocialMediasid.Value > 0)
            {
                if (_SocialMediasModel != null)
                {
                    _SocialMediasModel = _SocialMediasContext.GetSocialMedias().Where(x => x.SocialMediaID == SocialMediasid).FirstOrDefault();
                }
            }
            return(View(_SocialMediasModel));
        }
예제 #4
0
        private SelectList GetAllSocialMedia()
        {
            var _SocialMediaContexts = new Contexts.SocialMediasContexts();
            var list = _SocialMediaContexts.GetSocialMedias().OrderBy(x => x.SocialMediaNameTxt).Select(x => new SocialMediasModel()
            {
                SocialMediaID      = x.SocialMediaID,
                SocialMediaNameTxt = x.SocialMediaNameTxt
            }).ToList();
            var objSocialMedia = new SocialMediasModel();

            objSocialMedia.SocialMediaNameTxt = "-- Select Social Media --";
            objSocialMedia.SocialMediaID      = 0;
            list.Insert(0, objSocialMedia);
            var objselectlist = new SelectList(list, "SocialMediaID", "SocialMediaNameTxt");

            return(objselectlist);
        }
예제 #5
0
        public ActionResult CreateSocialMedias(SocialMediasModel _SocialMediasmodel, string command, FormCollection fm)
        {
            ViewBag.Title  = (_SocialMediasmodel.SocialMediaID > 0 ? "Edit " : "Add ") + " Social Media Details ";
            ViewBag.Submit = _SocialMediasmodel.SocialMediaID > 0 ? "Update" : "Save";
            var SocialMediasContext = new Contexts.SocialMediasContexts();

            if (string.IsNullOrEmpty(command))
            {
                if (SocialMediasContext.GetSocialMedias().Where(x => x.SocialMediaNameTxt == _SocialMediasmodel.SocialMediaNameTxt && _SocialMediasmodel.SocialMediaID != x.SocialMediaID).Any())
                {
                    ModelState.AddModelError("SocialMediaNameTxt", _SocialMediasmodel.SocialMediaNameTxt + " SocialMedias already exists.");
                    return(View(_SocialMediasmodel));
                }
                try
                {
                    if (ViewBag.Submit == "Save")
                    {
                        SocialMediasContext.AddSocialMedias(_SocialMediasmodel);
                        TempData["AlertMessage"] = "SocialMedias details saved successfully.";
                    }
                    else
                    {
                        SocialMediasContext.EditSocialMedias(_SocialMediasmodel);
                        TempData["AlertMessage"] = "SocialMedias details Updated successfully.";
                    }
                }
                catch
                {
                    TempData["AlertMessage"] = "Some error occured, Please try after some time.";
                }
            }
            var rvd = new RouteValueDictionary();

            rvd.Add("Column", Request.QueryString["Column"] != null ? Request.QueryString["Column"].ToString() : "SocialMediaNameTxt");
            rvd.Add("Direction", Request.QueryString["Direction"] != null ? Request.QueryString["Direction"].ToString() : "Ascending");
            rvd.Add("pagesize", Request.QueryString["pagesize"] != null ? Request.QueryString["pagesize"].ToString() : Models.Common._pageSize.ToString());
            rvd.Add("page", Request.QueryString["page"] != null ? Request.QueryString["page"].ToString() : Models.Common._currentPage.ToString());
            return(RedirectToAction("BlogSocialMediasListing", "SocialMedia", rvd));
        }
예제 #6
0
        public ActionResult BlogSocialMediasListing(GridSortOptions gridSortOptions, int?pagetype, int?page, int?pagesize, FormCollection fm, string objresult)
        {
            var _objContext = new Contexts.SocialMediasContexts();
            var pageSize    = pagesize.HasValue ? pagesize.Value : Models.Common._pageSize;
            var Page        = page.HasValue ? page.Value : Models.Common._currentPage;

            TempData["pager"] = pagesize;
            ViewBag.Title     = " SocialMedias Listing";
            var _SocialMediasModel = new SocialMediasModel();

            #region Ajax Call
            if (objresult != null)
            {
                AjaxRequest objAjaxRequest = JsonConvert.DeserializeObject <AjaxRequest>(objresult);//Convert json String to object Model
                if (objAjaxRequest.ajaxcall != null && !string.IsNullOrEmpty(objAjaxRequest.ajaxcall) && objresult != null && !string.IsNullOrEmpty(objresult))
                {
                    if (objAjaxRequest.ajaxcall == "paging")       //Ajax Call type = paging i.e. Next|Previous|Back|Last
                    {
                        Session["pageNo"] = Page;                  // stores the page no for status
                    }
                    else if (objAjaxRequest.ajaxcall == "sorting") //Ajax Call type = sorting i.e. column sorting Asc or Desc
                    {
                        Page = (Session["pageNo"] != null ? Convert.ToInt32(Session["pageNo"].ToString()) : Page);
                        Session["GridSortOption"] = gridSortOptions;
                        pagesize = (Session["PageSize"] != null ? Convert.ToInt32(Session["PageSize"].ToString()) : pagesize);
                    }
                    else if (objAjaxRequest.ajaxcall == "ddlPaging")//Ajax Call type = drop down paging i.e. drop down value 10, 25, 50, 100, ALL
                    {
                        Session["PageSize"]       = (Request.QueryString["pagesize"] != null ? Convert.ToInt32(Request.QueryString["pagesize"].ToString()) : pagesize);
                        Session["GridSortOption"] = gridSortOptions;
                        Session["pageNo"]         = Page;
                    }
                    else if (objAjaxRequest.ajaxcall == "status")//Ajax Call type = status i.e. Active/Inactive
                    {
                        Page            = (Session["pageNo"] != null ? Convert.ToInt32(Session["pageNo"].ToString()) : Page);
                        gridSortOptions = (Session["GridSortOption"] != null ? Session["GridSortOption"] as GridSortOptions : gridSortOptions);
                    }
                    else if (objAjaxRequest.ajaxcall == "displayorder")//Ajax Call type = Display Order i.e. drop down values
                    {
                        page            = (Session["pageNo"] != null ? Convert.ToInt32(Session["pageNo"].ToString()) : page);
                        gridSortOptions = (Session["GridSortOption"] != null ? Session["GridSortOption"] as GridSortOptions : gridSortOptions);
                    }
                    objAjaxRequest.ajaxcall = null;; //remove parameter value
                }
            }
            #endregion Ajax Call
            //This section is used to retain the values of page , pagesize and gridsortoption on complete page post back(Edit, Dlete)
            if (!Request.IsAjaxRequest() && Session["Edit/Delete"] != null && !string.IsNullOrEmpty(Session["Edit/Delete"].ToString()))
            {
                pagesize               = (Session["PageSize"] != null ? Convert.ToInt32(Session["PageSize"]) : Models.Common._pageSize);
                page                   = (Session["pageNo"] != null ? Convert.ToInt32(Session["pageNo"]) : Models.Common._currentPage);
                gridSortOptions        = (Session["GridSortOption"] != null ? Session["GridSortOption"] as GridSortOptions : gridSortOptions);
                Session["Edit/Delete"] = null;
            }
            else if (!Request.IsAjaxRequest() && Session["Edit/Delete"] == null)
            {
                //gridSortOptions.Column = "CreateDate";
                Session["PageSize"]       = null;
                Session["pageNo"]         = null;
                Session["GridSortOption"] = null;
            }
            var pagedViewModel = new PagedViewModel <SocialMediasModel>
            {
                ViewData          = ViewData,
                Query             = _objContext.GetSocialMedias().AsQueryable(),
                GridSortOptions   = gridSortOptions,
                DefaultSortColumn = "SocialMediaNameTxt",
                Page     = Page,
                PageSize = pageSize,
            }.Setup();

            if (Request.IsAjaxRequest())                                        // check if request comes from ajax, then return Partial view
            {
                return(View("BlogSocialMediasListingPartial", pagedViewModel)); // ("partial view name ")
            }
            else
            {
                return(View(pagedViewModel));
            }
        }