public async Task <List <ContentStyleModel> > GetAllContents(int SiteId, int ContentId)
        {
            if (ContentId == 0)
            {
                ContentId = -1;
            }

            List <ContentStyleModel> ContentList = new List <ContentStyleModel>();

            //List<ViewModel> Views = BORepository.GetAllViews(proxy).Result;
            List <SiteModel>            Sites = BORepository.GetAllSites(proxy, SiteId).Result;
            Dictionary <string, object> dict  = new Dictionary <string, object>();


            dict.Add("@Id", ContentId);
            dict.Add("@LoadOnlyActive", 0);
            dict.Add("@SiteId", SiteId);

            var dataSet = await proxy.ExecuteDataset("SP_ContentsSelect", dict);

            return((from DataRow row in dataSet.Tables[0].Rows
                    select new ContentStyleModel
            {
                Id = Convert.ToInt32(row["Id"].ToString()),
                Name = row["Name"].ToString(),
                Description = row["Description"].ToString(),
                IsActive = bool.Parse(row["IsActive"].ToString()),
                SiteID = Convert.ToInt32(row["SiteId"].ToString()),
                Type = Convert.ToInt32(row["Type"].ToString()),
                Orientation = row["Orientation"].ToString(),
                Data = (row["Data"].ToString() == "") ? "" : JsonConvert.DeserializeObject(row["Data"].ToString()).ToString(),
                SiteName = Sites.FirstOrDefault(sit => sit.Oid == SiteId).Name,
            }).ToList());
        }
Exemple #2
0
        public static async Task <List <SiteModel> > GetAllSites(WebApiProxy proxy, int Id = -1, string SiteName = "")
        {
            List <SiteModel>            SiteList = new List <SiteModel>();
            Dictionary <string, object> dict     = new Dictionary <string, object>();

            dict.Add("@Id", Id);
            dict.Add("@LoadOnlyActive", 0);
            dict.Add("@SiteName", SiteName);

            var dataSet = await proxy.ExecuteDataset("SP_SiteSelect", dict);

            if (!ReferenceEquals(dataSet, null) && dataSet.Tables.Count > 0)
            {
                return((from DataRow row in dataSet.Tables[0].Rows
                        select new SiteModel
                {
                    Oid = Convert.ToInt32(row["Id"].ToString()),
                    Name = row["Name"].ToString(),
                    Title = row["Title"].ToString(),
                    URL = row["url"].ToString(),
                    Logo = GetRowData <byte[]>(row["Logo"]),
                    IsActive = bool.Parse(row["IsActive"].ToString())
                }).ToList());
            }
            return(SiteList);
        }
Exemple #3
0
        public static async Task <int> AddUpdateRecord <T>(WebApiProxy proxy, T ModelObject, bool IsNewObject = false) where T : class
        {
            Dictionary <string, string> ProcedureInfo = GetProcedureInfo(ModelObject);

            System.ComponentModel.PropertyDescriptorCollection pdc = System.ComponentModel.TypeDescriptor.GetProperties(ModelObject);
            Dictionary <string, object> dicParams = pdc.Cast <PropertyDescriptor>().Where(item => ProcedureInfo.ContainsKey(item.Name)).ToDictionary(key => ProcedureInfo[key.Name], value => value.GetValue(ModelObject));

            if (IsNewObject)
            {
                dicParams["@Id"] = -1;
            }

            if (dicParams.ContainsKey("@Logo"))
            {
                dicParams["@Logo"] = 1014;
            }
            DataSet dataSet = await proxy.ExecuteDataset(ProcedureInfo["ProcedureName"], dicParams);

            if (dataSet != null && dataSet.Tables != null && dataSet.Tables.Count > 0)
            {
                if (dataSet.Tables[0].Rows != null && dataSet.Tables[0].Rows.Count > 0)
                {
                    int ID = Convert.ToInt32(dataSet.Tables[0].Rows[0][0].ToString());
                    return(ID);
                }
            }
            return(-1);
        }
Exemple #4
0
        public static async Task <List <ViewModel> > GetAllViews(WebApiProxy proxy, int SiteId, int Id = -1)
        {
            List <SiteModel>            Sites    = GetAllSites(proxy, SiteId).Result;
            List <ViewModel>            ViewList = new List <ViewModel>();
            Dictionary <string, object> dict     = new Dictionary <string, object>();

            dict.Add("@Id", Id);
            dict.Add("@SiteId", SiteId);
            dict.Add("@LoadOnlyActive", 0);
            dict.Add("@ViewName", "");
            var dataSet = await proxy.ExecuteDataset("SP_ViewSelect", dict);

            if (!ReferenceEquals(dataSet, null) && dataSet.Tables.Count > 0)
            {
                return((from DataRow row in dataSet.Tables[0].Rows
                        select new ViewModel
                {
                    Oid = Convert.ToInt32(row["Id"].ToString()),
                    Name = row["Name"].ToString(),
                    Title = row["Title"].ToString(),
                    IsActive = bool.Parse(row["IsActive"].ToString()),
                    IsDefault = bool.Parse(row["IsDefault"].ToString()),
                    Authorized = bool.Parse(row["Authorized"].ToString()),
                    Orientation = row["Orientation"].ToString(),
                    CreateMenu = CheckMenuExistOrNot(proxy, SiteId, Convert.ToInt32(row["Id"].ToString())).Result,
                    SiteID = row["SiteId"].ToString() == string.Empty ? 0 : Convert.ToInt32(row["SiteId"].ToString()),
                    SelectSite = Sites.FirstOrDefault(it => it.Oid == Convert.ToInt32(row["SiteId"].ToString())).Title,
                }).ToList());
            }
            return(ViewList);
        }
Exemple #5
0
        public static async Task <List <ContentOfViewModel> > GetContentViews(WebApiProxy proxy, int SiteId)
        {
            List <SiteModel>         Sites    = GetAllSites(proxy, SiteId).Result;
            List <ViewModel>         Views    = GetAllViews(proxy, SiteId).Result;
            List <ContentStyleModel> Contents = GetAllContents(proxy, SiteId).Result;

            Dictionary <string, object> dict = new Dictionary <string, object>();

            dict.Add("@Id", -1);
            dict.Add("@LoadOnlyActive", 0);
            dict.Add("@SiteId", SiteId);

            var dataSet = await proxy.ExecuteDataset("SP_ContentOfViewSelect", dict);

            if (!ReferenceEquals(dataSet, null) && dataSet.Tables.Count > 0)
            {
                return((from DataRow row in dataSet.Tables[0].Rows
                        select new ContentOfViewModel
                {
                    Id = Convert.ToInt32(row["Id"].ToString()),
                    ContentId = Convert.ToInt32(row["ContentId"].ToString()),
                    ViewId = Convert.ToInt32(row["ViewId"].ToString()),
                    ViewName = Views.FirstOrDefault(i => i.Oid == Convert.ToInt32(row["ViewId"].ToString())).Name,
                    ContentName = Contents.FirstOrDefault(c => c.Id == Convert.ToInt32(row["ContentId"].ToString())).Name,
                    SiteId = row["SiteId"].ToString() == string.Empty ? 0 : Convert.ToInt32(row["SiteId"].ToString()),
                    SiteName = Sites.FirstOrDefault(it => it.Oid == Convert.ToInt32(row["SiteId"].ToString())).Title,
                    Order = Convert.ToInt32(row["Order"].ToString()),
                }).ToList());
            }
            return(new List <ContentOfViewModel>());
        }
Exemple #6
0
        public static async Task <List <ViewContentModel> > GetAllContents(WebApiProxy proxy, int siteId, int viewId)
        {
            List <SiteModel>            Sites       = GetAllSites(proxy).Result;
            List <ViewContentModel>     ContentList = new List <ViewContentModel>();
            Dictionary <string, object> dict        = new Dictionary <string, object>();

            dict.Add("@ViewId", viewId);
            dict.Add("@SiteId", siteId);

            var dataSet = await proxy.ExecuteDataset("SP_GetViewContents", dict);

            if (!ReferenceEquals(dataSet, null) && dataSet.Tables.Count > 0)
            {
                ContentList = dataSet.Tables[0].AsEnumerable().Select(row =>
                                                                      new ViewContentModel
                {
                    Id          = Convert.ToInt32(row["Id"].ToString()),
                    Name        = row["Name"].ToString(),
                    Type        = GetRowData <Int32>(row["Type"]),
                    Orientation = GetRowData <string>(row["Orientation"]),
                    Data        = JsonConvert.DeserializeObject(row["Data"].ToString()).ToString(),
                    Order       = GetRowData <Int32>(row["Order"]),
                    MaxOrder    = Convert.ToInt32(row["MaxOrder"]),
                    ViewID      = viewId,
                    SiteID      = siteId
                }).OrderBy(t => t.Order).ToList();
            }
            return(ContentList);
        }
Exemple #7
0
        public static async Task <List <MenuModel> > GetAllMenu(WebApiProxy proxy, int SiteId)
        {
            List <SiteModel>            Sites = GetAllSites(proxy, SiteId).Result;
            List <ViewModel>            Views = GetAllViews(proxy, SiteId).Result;
            Dictionary <string, object> dict  = new Dictionary <string, object>();

            dict.Add("@Id", -1);
            dict.Add("@SiteId", SiteId);
            dict.Add("@ViewId", -1);
            var dataSet = await proxy.ExecuteDataset("SP_MenuSelect", dict);

            if (!ReferenceEquals(dataSet, null) && dataSet.Tables.Count > 0 && dataSet.Tables[0].Rows.Count > 0)
            {
                return((from DataRow row in dataSet.Tables[0].Rows
                        select new MenuModel
                {
                    Id = Convert.ToInt32(row["Id"].ToString()),
                    Name = row["Name"].ToString(),
                    URL = row["URL"].ToString(),
                    IsExternal = Convert.ToBoolean(row["IsExternal"].ToString()),
                    Order = Convert.ToInt32(row["Order"].ToString()),
                    MaxOrder = Convert.ToInt32(row["MaxOrder"].ToString()),
                    ViewId = Convert.ToInt32(row["ViewId"].ToString()),
                    SiteId = row["SiteId"].ToString() == string.Empty ? 0 : Convert.ToInt32(row["SiteId"].ToString()),
                    SiteName = Sites.FirstOrDefault(it => it.Oid == Convert.ToInt32(row["SiteId"].ToString())).Title,
                    ViewName = Views.FirstOrDefault(it => it.Oid == Convert.ToInt32(row["ViewId"].ToString())).Name
                }).ToList());
            }
            return(new List <MenuModel>());
        }
Exemple #8
0
        public static async Task <int> AddMenu(WebApiProxy proxy, MenuModel MenuObject, bool IsNewObject = false)
        {
            Dictionary <string, object> dicParams = new Dictionary <string, object>();

            if (IsNewObject)
            {
                dicParams.Add("@Id", -1);
            }
            else
            {
                dicParams.Add("@Id", MenuObject.Id);
            }
            dicParams.Add("@Name", MenuObject.Name);
            dicParams.Add("@URL", MenuObject.URL);
            dicParams.Add("@IsExternal", MenuObject.IsExternal);
            dicParams.Add("@Order", MenuObject.Order);
            dicParams.Add("@ViewId", MenuObject.ViewId);
            dicParams.Add("@SiteId", MenuObject.SiteId);

            DataSet dataSet = await proxy.ExecuteDataset("SP_MenuAddUp", dicParams);

            if (dataSet != null && dataSet.Tables != null && dataSet.Tables.Count > 0)
            {
                if (dataSet.Tables[0].Rows != null && dataSet.Tables[0].Rows.Count > 0)
                {
                    int SiteMisc = Convert.ToInt32(dataSet.Tables[0].Rows[0][0].ToString());
                    return(SiteMisc);
                }
            }
            return(-1);
        }
Exemple #9
0
        public static async Task <List <SiteDbModel> > GetAllSiteDb(WebApiProxy proxy, int SiteId)
        {
            List <SiteModel>            Sites = GetAllSites(proxy, SiteId).Result;
            Dictionary <string, object> dict  = new Dictionary <string, object>();

            dict.Add("@Id", -1);
            dict.Add("@SiteId", SiteId);
            var dataSet = await proxy.ExecuteDataset("SP_SiteDBSelect", dict);

            if (!ReferenceEquals(dataSet, null) && dataSet.Tables.Count > 0 && Sites.Count > 0)
            {
                return((from DataRow row in dataSet.Tables[0].Rows
                        select new SiteDbModel
                {
                    Id = Convert.ToInt32(row["Id"].ToString()),
                    Name = row["Name"].ToString(),
                    Server = row["Server"].ToString(),
                    Database = row["Database"].ToString(),
                    UserID = row["UserID"].ToString(),
                    Password = row["Password"].ToString(),
                    Description = row["Description"].ToString(),
                    SiteId = row["SiteId"].ToString() == string.Empty ? 0 : Convert.ToInt32(row["SiteId"].ToString()),
                    SiteName = Sites.FirstOrDefault().Title
                }).ToList());
            }
            return(new List <SiteDbModel>());
        }
Exemple #10
0
        public static async Task <int> AddSiteMisc(WebApiProxy proxy, SiteMiscModel SiteMiscObject, bool IsNewObject = false)
        {
            Dictionary <string, object> dicParams = new Dictionary <string, object>();

            if (IsNewObject)
            {
                dicParams.Add("@Id", -1);
            }
            else
            {
                dicParams.Add("@Id", SiteMiscObject.Id);
            }
            dicParams.Add("@Key", SiteMiscObject.Key);
            dicParams.Add("@Value", SiteMiscObject.Value);
            dicParams.Add("@SiteId", SiteMiscObject.SiteId);

            DataSet dataSet = await proxy.ExecuteDataset("SP_SiteMiscAddUp", dicParams);

            if (dataSet != null && dataSet.Tables != null && dataSet.Tables.Count > 0)
            {
                if (dataSet.Tables[0].Rows != null && dataSet.Tables[0].Rows.Count > 0)
                {
                    int SiteMisc = Convert.ToInt32(dataSet.Tables[0].Rows[0][0].ToString());
                    return(SiteMisc);
                }
            }
            return(-1);
        }
Exemple #11
0
        public static async Task <int> AddSiteDB(WebApiProxy proxy, SiteDbModel SiteDBObject, bool IsNewObject = false)
        {
            Dictionary <string, object> dicParams = new Dictionary <string, object>();

            if (IsNewObject)
            {
                dicParams.Add("@Id", -1);
            }
            else
            {
                dicParams.Add("@Id", SiteDBObject.Id);
            }
            dicParams.Add("@Name", SiteDBObject.Name);
            dicParams.Add("@Server", SiteDBObject.Server);
            dicParams.Add("@Database", SiteDBObject.Database);
            dicParams.Add("@UserID", SiteDBObject.UserID);
            dicParams.Add("@Password", SiteDBObject.Password);
            dicParams.Add("@Description", SiteDBObject.Description);
            dicParams.Add("@SiteId", SiteDBObject.SiteId);

            DataSet dataSet = await proxy.ExecuteDataset("SP_SiteDBAddUp", dicParams);

            if (dataSet != null && dataSet.Tables != null && dataSet.Tables.Count > 0)
            {
                if (dataSet.Tables[0].Rows != null && dataSet.Tables[0].Rows.Count > 0)
                {
                    int SiteDB = Convert.ToInt32(dataSet.Tables[0].Rows[0][0].ToString());
                    return(SiteDB);
                }
            }
            return(-1);
        }
Exemple #12
0
        public static async Task <int> AddView(WebApiProxy proxy, ViewModel ViewObject, bool IsNewObject = false)
        {
            Dictionary <string, object> dicParams = new Dictionary <string, object>();

            if (IsNewObject)
            {
                dicParams.Add("@Id", -1);
            }
            else
            {
                dicParams.Add("@Id", ViewObject.Oid);
            }
            dicParams.Add("@Name", ViewObject.Name);
            dicParams.Add("@Title", ViewObject.Title);
            dicParams.Add("@Logo", 1014);
            dicParams.Add("@Orientation", ViewObject.Orientation);
            if (ViewObject.IsActive)
            {
                dicParams.Add("@IsActive", "1");
            }
            else
            {
                dicParams.Add("@IsActive", "0");
            }

            if (ViewObject.Authorized)
            {
                dicParams.Add("@Authorized", "1");
            }
            else
            {
                dicParams.Add("@Authorized", "0");
            }

            if (ViewObject.IsDefault)
            {
                dicParams.Add("@IsDefault", "1");
            }
            else
            {
                dicParams.Add("@IsDefault", "0");
            }
            dicParams.Add("@SiteId", ViewObject.SiteID);

            DataSet dataSet = await proxy.ExecuteDataset("SP_ViewAddUp", dicParams);

            if (dataSet != null && dataSet.Tables != null && dataSet.Tables.Count > 0)
            {
                if (dataSet.Tables[0].Rows != null && dataSet.Tables[0].Rows.Count > 0)
                {
                    int ViewID = Convert.ToInt32(dataSet.Tables[0].Rows[0][0].ToString());
                    return(ViewID);
                }
            }
            return(-1);
        }
Exemple #13
0
        public static async Task <bool> CheckMenuExistOrNot(WebApiProxy proxy, int siteId, int ViewID)
        {
            Dictionary <string, object> dict = new Dictionary <string, object>();

            dict.Add("@Id", -1);
            dict.Add("@SiteId", siteId);
            dict.Add("@ViewId", ViewID);
            var dataSet = await proxy.ExecuteDataset("SP_MenuSelect", dict);

            if (!ReferenceEquals(dataSet, null) && dataSet.Tables.Count > 0)
            {
                if (dataSet.Tables[0].Rows.Count > 0)
                {
                    return(true);
                }
            }
            return(false);
        }
Exemple #14
0
        public static async Task <List <ContentStyleModel> > GetAllContents(WebApiProxy proxy, int SiteId, bool loadOnlyActive = false)
        {
            List <SiteModel>            Sites       = GetAllSites(proxy).Result;
            List <ContentStyleModel>    ContentList = new List <ContentStyleModel>();
            Dictionary <string, object> dict        = new Dictionary <string, object>();

            dict.Add("@Id", -1);

            if (loadOnlyActive)
            {
                dict.Add("@LoadOnlyActive", 1);
            }
            else
            {
                dict.Add("@LoadOnlyActive", 0);
            }
            dict.Add("@SiteId", SiteId);

            var dataSet = await proxy.ExecuteDataset("SP_ContentsSelect", dict);

            if (!ReferenceEquals(dataSet, null) && dataSet.Tables.Count > 0)
            {
                return((from DataRow row in dataSet.Tables[0].Rows
                        select new ContentStyleModel
                {
                    Id = Convert.ToInt32(row["Id"].ToString()),
                    Name = row["Name"].ToString(),
                    Description = row["Description"].ToString(),
                    IsActive = bool.Parse(row["IsActive"].ToString()),
                    SiteID = Convert.ToInt32(row["SiteId"].ToString()),
                    Type = Convert.ToInt32(row["Type"].ToString()),
                    Orientation = row["Orientation"].ToString(),
                    Data = JsonConvert.DeserializeObject(row["Data"].ToString()).ToString(),
                    //Order = Convert.ToInt32(row["Order"].ToString()),
                    SiteName = Sites.FirstOrDefault(it => it.Oid == Convert.ToInt32(row["SiteId"].ToString())).Title,
                    // SiteName = Sites.FirstOrDefault(sit => sit.Oid == SiteId).Name,
                }).ToList());
            }
            return(ContentList);
        }
Exemple #15
0
        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);
        }
Exemple #16
0
        public static async Task <List <SiteMiscModel> > GetAllSiteMISC(WebApiProxy proxy, int siteId)
        {
            List <SiteModel>            Sites = GetAllSites(proxy).Result;
            Dictionary <string, object> dict  = new Dictionary <string, object>();

            dict.Add("@Id", -1);
            dict.Add("@SiteId", siteId);
            var dataSet = await proxy.ExecuteDataset("SP_SiteMiscSelect", dict);

            if (!ReferenceEquals(dataSet, null) && dataSet.Tables.Count > 0)
            {
                return((from DataRow row in dataSet.Tables[0].Rows
                        select new SiteMiscModel
                {
                    Id = Convert.ToInt32(row["Id"].ToString()),
                    Key = row["Key"].ToString(),
                    Value = row["Value"].ToString(),
                    SiteId = row["SiteId"].ToString() == string.Empty ? 0 : Convert.ToInt32(row["SiteId"].ToString()),
                    SiteName = Sites.FirstOrDefault(it => it.Oid == Convert.ToInt32(row["SiteId"].ToString())).Title
                }).ToList());
            }
            return(new List <SiteMiscModel>());
        }
Exemple #17
0
        public static async Task <List <SiteModel> > GetSearchSite(WebApiProxy proxy, string viewObject)
        {
            List <SiteModel>            SearchList = new List <SiteModel>();
            Dictionary <string, object> dicParams  = new Dictionary <string, object>();

            dicParams.Add("@Name", viewObject);

            var dataSet = await proxy.ExecuteDataset("SP_GetSearchList", dicParams);

            if (!ReferenceEquals(dataSet, null) && dataSet.Tables.Count > 0)
            {
                return((from DataRow row in dataSet.Tables[0].Rows
                        select new SiteModel
                {
                    Oid = Convert.ToInt32(row["Id"].ToString()),
                    Name = row["Name"].ToString(),
                    Title = row["Title"].ToString(),
                    URL = row["url"].ToString(),
                    Logo = GetRowData <byte[]>(row["Logo"]),
                    IsActive = bool.Parse(row["IsActive"].ToString())
                }).ToList());
            }
            return(SearchList);
        }
        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());
            }
        }
Exemple #19
0
        public async Task <ActionResult> CreateUpdContentOfView(int ContentId, int ViewId, int SiteId, int Order, int Id = 0)
        {
            try
            {
                if (ContentId == -1 || ViewId == -1)
                {
                    return(RedirectToAction("GetAllContentOfView", new { SiteId = SiteId }));
                }

                if (ModelState.IsValid)
                {
                    int ContentID = 0;
                    if (Id == 0)
                    {
                        Id = -1;
                    }

                    Dictionary <string, object> dicParams = new Dictionary <string, object>();

                    dicParams.Add("@Id", Id);
                    dicParams.Add("@ContentId", ContentId);
                    dicParams.Add("@ViewId", ViewId);
                    dicParams.Add("@SiteId", SiteId);
                    dicParams.Add("@Order", Order);

                    //await Task.Run(() =>
                    //{
                    DataSet dataSet = await proxy.ExecuteDataset("SP_ContentOfViewAddUp", dicParams);

                    //});

                    if (dataSet != null && dataSet.Tables != null && dataSet.Tables.Count > 0)
                    {
                        if (dataSet.Tables[0].Rows != null && dataSet.Tables[0].Rows.Count > 0)
                        {
                            ContentID = Convert.ToInt32(dataSet.Tables[0].Rows[0][0].ToString());
                        }
                    }

                    if (ContentID > 0)
                    {
                        ViewBag.Message = "Content of View added successfully.";
                    }
                    else
                    {
                        ViewBag.Message = "Problem occured while adding content, kindly contact our support team.";
                    }

                    ActionResult MainView = null;
                    await Task.Run(() =>
                    {
                        MainView = GetAllContentOfView(SiteId).Result;
                    });

                    return(MainView);
                }
                return(View());
            }
            catch
            {
                return(View());
            }
        }