public async Task <ActionResult> GetAllSite() { ModelState.Clear(); 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)); }
public async Task <ActionResult> EditSiteDetails(int id, int tid = 0) { ModelState.Clear(); if (tid != 0) { List <SiteModel> sites = new List <SiteModel>(); await Task.Run(() => { sites.AddRange(BORepository.GetAllSites(proxy).Result); }); CombineSiteModel siteObject = new CombineSiteModel(); siteObject.SiteView = sites.FirstOrDefault(site => site.Oid == id); siteObject.SiteList = sites; return(View("AddSite1", siteObject)); } else { return(RedirectToAction("GetAllSite")); } }
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()); } }