public async Task <JsonResult> AddUpdateRecord(ContentStyleModel modeldata) { Dictionary <string, object> ContentData = new Dictionary <string, object>(); if (modeldata.Type == 0) { ContentData.Add("sd", modeldata.Data); } else if (modeldata.Type == 1) { ContentData.Add("v", modeldata.views.ToString().Substring(0, modeldata.views.Length - 1)); } else if (modeldata.Type == 2) { ContentData.Add("st", modeldata.searchty.ToString().Substring(0, modeldata.searchty.Length - 1)); } modeldata.Data = JsonConvert.SerializeObject(ContentData); string Status = string.Empty; await Task.Run(() => { Status = base.BaseAddUpdateRecord(modeldata, ModelState, proxy).Result; } ); return(Json(new { status = Status })); }
public ActionResult DeleteRecord(int id, bool IsDefault, int Siteid) { string Status = string.Empty; ContentStyleModel modeldata = new ContentStyleModel(); modeldata.Id = id; modeldata.SiteID = Siteid; if (!IsDefault) { Status = base.BaseDeleteRecord(modeldata, ModelState, proxy); } return(RedirectToAction("GetContentPage", new { SiteId = Siteid })); }
public static async Task <int> AddContentStyle(WebApiProxy proxy, ContentStyleModel ContentStyleModelObject) { Dictionary <string, object> dicParams = new Dictionary <string, object>(); dicParams.Add("@Id", "-1"); dicParams.Add("@Name", ContentStyleModelObject.Name); dicParams.Add("@Type", ContentStyleModelObject.Type); dicParams.Add("@Orientation", ContentStyleModelObject.Orientation); dicParams.Add("@Data", ContentStyleModelObject.Data); dicParams.Add("@Description", ContentStyleModelObject.Description); //dicParams.Add("@Order", ContentStyleModelObject.Order); if (ContentStyleModelObject.IsActive) { dicParams.Add("@IsActive", "1"); } else { dicParams.Add("@IsActive", "0"); } dicParams.Add("@SiteID", ContentStyleModelObject.SiteID); //DataSet dataSet = null; //await Task.Run(() => //{ DataSet dataSet = await proxy.ExecuteDataset("SP_ContentsAddUp", dicParams); //}); if (dataSet != null && dataSet.Tables != null && dataSet.Tables.Count > 0) { if (dataSet.Tables[0].Rows != null && dataSet.Tables[0].Rows.Count > 0) { int ContentID = Convert.ToInt32(dataSet.Tables[0].Rows[0][0].ToString()); return(ContentID); } } return(-1); }
public async Task <ActionResult> CreateSite(int Oid, string Name, string URL, string Title, string IsActive, object Logo) { if (Oid == 0) { Oid = -1; } if (string.IsNullOrEmpty(Name) || string.IsNullOrEmpty(URL) || string.IsNullOrEmpty(Title)) { return(RedirectToAction("GetAllSite")); } try { if (ModelState.IsValid) { Dictionary <string, object> dicParams = new Dictionary <string, object>(); dicParams.Add("@Id", Oid); dicParams.Add("@Name", Name); dicParams.Add("@url", URL); dicParams.Add("@Logo", new ComplexDataModel(typeof(Byte[]), CommonClass.GetImage(Convert.ToString(Logo)))); dicParams.Add("@Title", Title); dicParams.Add("@IsActive", Convert.ToBoolean(IsActive)); DataSet dataSet = null; await Task.Run(() => { dataSet = proxy.ExecuteDataset("SP_SiteAddUp", dicParams).Result; }); int SiteID = 0; if (Oid == -1) { if (dataSet != null && dataSet.Tables != null && dataSet.Tables.Count > 0) { if (dataSet.Tables[0].Rows != null && dataSet.Tables[0].Rows.Count > 0) { SiteID = Convert.ToInt32(dataSet.Tables[0].Rows[0][0].ToString()); ViewModel DefaultView = new ViewModel(); DefaultView.Name = "Home"; DefaultView.Title = "Home"; DefaultView.Logo = CommonClass.GetImage(Server.MapPath(@"..\images\V2ViewLogo.png")); DefaultView.Orientation = "0"; DefaultView.IsActive = true; DefaultView.Authorized = true; DefaultView.IsDefault = true; DefaultView.SiteID = SiteID; int ViewID = 0; await Task.Run(() => { ViewID = BORepository.AddView(proxy, DefaultView, true).Result; }); if (ViewID > 0) { ContentStyleModel DefaultContent = new ContentStyleModel(); Dictionary <string, object> ContentData = new Dictionary <string, object>(); DefaultContent.Name = "Home"; string welcomebody = @"<p><span style='font-size: medium;'><b><span style='text-decoration: underline;'>This is our default template.</span></b></span></p> <p><strong><span style='text-decoration: underline;'>Welcome to our site.<img src='http://localhost:49791/Scripts/tinymce/plugins/emotions/img/smiley-smile.gif' alt='Smile' title='Smile' border='0' /></span></strong></p>"; ContentData.Add("sd", welcomebody); ContentData.Add("st", -1); ContentData.Add("v", ViewID); DefaultContent.Type = 0; DefaultContent.Orientation = "0"; DefaultContent.Data = JsonConvert.SerializeObject(ContentData); DefaultContent.Description = "Welcome"; //DefaultContent.Order = 1; DefaultContent.IsActive = true; DefaultContent.SiteID = SiteID; int ContentID = 0; await Task.Run(() => { ContentID = BORepository.AddContentStyle(proxy, DefaultContent).Result; }); } } } } if (SiteID != 0) { ViewBag.Message = "Site added successfully."; } else { ViewBag.Message = "Problem occured while creating site, kindly contact our support team."; } List <SiteModel> sites = new List <SiteModel>(); await Task.Run(() => { sites.AddRange(BORepository.GetAllSites(proxy).Result); }); CombineSiteModel siteObject = new CombineSiteModel(); siteObject.SiteList = sites; siteObject.SiteView = new SiteModel(); return(View("AddSite1", siteObject)); } return(View()); } catch { return(View()); } }
public async Task <ActionResult> GetEdiContentPage(int Contentid = 0, int SiteId = 0) { ModelState.Clear(); if (Contentid != 0) { // int temp = ViewBag.Site; List <ContentStyleModel> contents = new List <ContentStyleModel>(); List <ViewModel> ObjViewList = new List <ViewModel>(); CombineContentModel combineContentModel = new CombineContentModel(); ContentStyleModel objContentstyle = new ContentStyleModel(); Dictionary <string, object> dictData = new Dictionary <string, object>(); //List<int> STyList =new List<int> (); await Task.Run(() => { contents.AddRange(GetAllContents(SiteId, 0).Result); ObjViewList.AddRange(BORepository.GetAllViews(proxy, SiteId).Result); }); if (contents.Count > 0) { combineContentModel.SiteName = contents[0].SiteName; combineContentModel.SiteID = contents[0].SiteID; } combineContentModel.SiteID = SiteId; PubSiteID = SiteId; combineContentModel.ContentView = contents.FirstOrDefault(item => item.Id == Contentid); combineContentModel.ContentList = contents; combineContentModel.ViewList = ObjViewList; //ViewBag.Site = PubSiteID; foreach (var item in contents) { if (item.Id == Contentid) { combineContentModel.ContentView.Orientation = item.Orientation; combineContentModel.ContentView.Type = item.Type; dictData = JsonConvert.DeserializeObject <Dictionary <string, object> >(item.Data.ToString()); foreach (var _item in dictData) { if (_item.Key == "sd") { combineContentModel.ContentView.Data = _item.Value.ToString(); } else if (_item.Key == "st") { combineContentModel.ContentView.STyList = new List <int>(Array.ConvertAll(_item.Value.ToString().Split(','), int.Parse)); } else if (_item.Key == "v") { combineContentModel.ContentView.VTyList = new List <int>(Array.ConvertAll((string.IsNullOrEmpty(_item.Value.ToString()) ? -1 : _item.Value).ToString().Split(','), int.Parse)); } else { } } } } return(View("ContentPanel", combineContentModel)); } else { return(RedirectToAction("GetContentPage", new { SiteId = SiteId })); } }