/Core/Core.cs
C# | 1000 lines | 561 code | 40 blank | 399 comment | 0 complexity | 887b8847d92248bcf3a006897c69096a MD5 | raw file
Possible License(s): LGPL-2.1
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Data.Linq;
- using DB;
- using Lib;
- using SystemBase;
- using System.Runtime.Serialization;
- using System.ComponentModel.DataAnnotations;
- using System.Web;
- using System.Xml.Linq;
-
- namespace Core
- {
- /// <summary>
- /// Project Class
- /// </summary>
- public class Project : ObjectBase
- {
- #region Properties
- /// <summary>
- /// ID of Projects table
- /// </summary>
- public int? ID { get; set; }
- /// <summary>
- /// Slug (URL) field of Projects table
- /// </summary>
- [Required(ErrorMessage = "Slug is required")]
- public string Slug { get; set; }
- /// <summary>
- /// Title field of Projects table
- /// </summary>
- [Required(ErrorMessage = "Name of project is required")]
- public string Title { get; set; }
- /// <summary>
- /// Summary field of Projects table
- /// </summary>
- [DisplayFormat(ConvertEmptyStringToNull = false)]
- public string Summary { get; set; }
- /// <summary>
- /// Credits field of Projects table
- /// </summary>
- [DisplayFormat(ConvertEmptyStringToNull = false)]
- public string Credits { get; set; }
- /// <summary>
- /// SmallText field of Projects table
- /// </summary>
- [DisplayFormat(ConvertEmptyStringToNull = false)]
- public string SmallText { get; set; }
- /// <summary>
- /// SmallImg image file that is posted from form
- /// </summary>
- public HttpPostedFileWrapper SmallImg { get; set; }
- /// <summary>
- /// SmallImgName field of Projects table
- /// </summary>
- public string SmallImgName { get; set; }
- /// <summary>
- /// BackgroundColor field of Projects table
- /// </summary>
- public string BackgroundColor { get; set; }
- /// <summary>
- /// List of categories in project
- /// </summary>
- public List<int> ProjectCategories { get; set; }
- /// <summary>
- /// String of all category names
- /// </summary>
- public string CategoryNames { get; set; }
- /// <summary>
- /// IsPublished field of Projects table
- /// </summary>
- public bool? IsPublished { get; set; }
- /// <summary>
- /// SortIndex field of Projects table
- /// </summary>
- public int? SortIndex { get; set; }
- /// <summary>
- /// Keywords for meta tag
- /// </summary>
- public string Keywords { get; set; }
- /// <summary>
- /// Description for meta tag
- /// </summary>
- public string Description { get; set; }
-
- #endregion
-
- #region Methods
- /// <summary>
- /// CRUD Operation on Projects table
- /// </summary>
- /// <param name="Iud"></param>
- /// <param name="ProjectID"></param>
- /// <param name="Slug"></param>
- /// <param name="SmallImg"></param>
- /// <param name="Title"></param>
- /// <param name="SmallText"></param>
- /// <param name="Summary"></param>
- /// <param name="Credits"></param>
- /// <param name="BackgroundColor"></param>
- /// <param name="IsPiblished"></param>
- /// <param name="SortIndex"></param>
- ///
- public void TSP_Projects(byte Iud, int? ProjectID, string Slug, string SmallImg, string Title, string SmallText, string Summary, string Credits, string BackgroundColor, bool? IsPiblished, int? SortIndex,string Keywords,string Description )
- {
- TryExecute(string.Format("Core.Project.TSP_Projects:" +
- "Iud {0}, ProjectID {1}, Slug {2}, SmallImg {3}, Title {4}, SmallText {5}, Summary {6}, Credits {7}, BackgroundColor {8}, IsPiblished {9}, SortIndex {10}"
- , Iud, ProjectID, Slug, SmallImg, Title, SmallText, Summary, Credits, BackgroundColor, IsPiblished, SortIndex), () =>
- {
- using (var db = ConnectionFactory.GetDBCoreDataContext())
- {
- db.tsp_Projects(Iud, ref ProjectID, Slug, SmallImg, Title, SmallText, Summary, Credits, BackgroundColor, IsPiblished, SortIndex, Keywords, Description);
- ID = ProjectID;
- }
- });
- }
- /// <summary>
- /// If Iud = 0 - Update Project Table and delete/insert values in ProjectCategories table via ProjectID
- /// </summary>
- /// <param name="Iud"></param>
- /// <param name="Xml"></param>
- public void TX_Projects(byte Iud, XElement Xml)
- {
- TryExecute(string.Format("Core.Project.TX_Projects"), () =>
- {
- using (var db = ConnectionFactory.GetDBCoreDataContext())
- {
- db.tx_Projects(Iud, Xml);
- }
- });
- }
- /// <summary>
- /// Get Projects List
- /// </summary>
- /// <param name="Published">true - published; false - not published; null both</param>
- public List<Project> ListProjects(bool? Published)
- {
- return TryToGetList<Project>(string.Format("Core.Project.ListProjects: Published {0}", Published), () =>
- {
- using (var db = ConnectionFactory.GetDBCoreDataContext())
- {
- return db.List_Pojects(Published).OrderBy(pro => pro.SortIndex).OrderByDescending(pro => pro.CRTime).Select(pro => new Project()
- {
- ID = pro.ProjectID
- , Slug = pro.Slug
- , Title = pro.Title
- , SmallText = pro.SmallText
- , SmallImgName = pro.SmallImg
- , BackgroundColor = pro.BackgroundColor
- , Summary = pro.Summary
- , Credits = pro.Credits
- , IsPublished = pro.IsPublished
- , SortIndex = pro.SortIndex
- , CategoryNames = pro.Categories
- ,Keywords = pro.KeyWords
- ,Description = pro.Description
- }).ToList();
- }
- });
-
- }
- /// <summary>
- /// Get project raw by project ID
- /// </summary>
- /// <param name="ID"></param>
- /// <returns></returns>
- public Project GetProjectByID(int ID)
- {
- return TryToReturn<Project>(string.Format("Core.Project.GetProjectByID: ID {0}", ID), () =>
- {
- using (var db = ConnectionFactory.GetDBCoreDataContext())
- {
- return db.Get_Project_By_ID(ID).Select(pro => new Project()
- {
- ID = pro.ProjectID
- ,Slug = pro.Slug
- ,Title = pro.Title
- ,SmallText = pro.SmallText
- ,SmallImgName = pro.SmallImg
- ,BackgroundColor = pro.BackgroundColor
- ,Summary = pro.Summary
- ,Credits = pro.Credits
- ,IsPublished = pro.IsPublished
- ,SortIndex = pro.SortIndex
- ,Keywords = pro.KeyWords
- ,Description = pro.Description
- }).SingleOrDefault();
- }
- });
- }
- /// <summary>
- /// Get project raw by Slug
- /// </summary>
- /// <param name="Slug"></param>
- public void GetProjectBySlug(string Slug)
- {
- TryExecute(string.Format("Core.Project.GetProjectBySlug: Slug {0}", Slug), () =>
- {
- using (var db = ConnectionFactory.GetDBCoreDataContext())
- {
- XElement X = db.GetSingleProjectBySlug(Slug);
- ID = X.IntValueOf("project_id");
- Slug = X.ValueOf("slug");
- Title = X.ValueOf("title");
- SmallText = X.ValueOf("small_text");
- SmallImgName = X.ValueOf("small_img");
- BackgroundColor = X.ValueOf("background_color");
- Summary = X.ValueOf("summary");
- Credits = X.ValueOf("credits");
- IsPublished = X.BooleanValueOf("is_published");
- SortIndex = X.IntValueOf("sort_index");
- Keywords = X.ValueOf("keywords");
- Description = X.ValueOf("description");
- }
- });
- }
- /// <summary>
- /// Check if Slug is unique. (true unique, false not unique)
- /// </summary>
- /// <param name="_Slug"></param>
- public bool? IsSlugUnique(string _Slug)
- {
- return TryToReturn<bool?>(string.Format("Core.Project.IsSlugUnique: Slug {0}", _Slug), () =>
- {
- using (var db = ConnectionFactory.GetDBCoreDataContext())
- {
- return db.Is_Slug_Unique(_Slug);
- }
- });
- }
-
- #endregion
- }
-
- /// <summary>
- /// ProjectCategory Class
- /// </summary>
- public class ProjectCategory : ObjectBase
- {
- #region Properties
- /// <summary>
- /// ID field of ProjectCategory table
- /// </summary>
- public int ID { get; set; }
- /// <summary>
- /// ProjectID field of ProjectCategory table
- /// </summary>
- public int? ProjectID { get; set; }
- /// <summary>
- /// CategoryID field of ProjectCategory table
- /// </summary>
- public int? CategoryID { get; set; }
- #endregion
-
- #region Methods
- /// <summary>
- /// Get list of ProjectCategory by ProjectID
- /// </summary>
- /// <param name="ProjectID"></param>
- /// <returns></returns>
- public List<ProjectCategory> ListProjectCategories(int ProjectID)
- {
- return TryToGetList<ProjectCategory>(string.Format("Core.Project.ListProjectCategories: ProjectID {0}", ProjectID), () =>
- {
- using (var db = ConnectionFactory.GetDBCoreDataContext())
- {
- return db.List_PojectCategories(ProjectID).Select(pro => new ProjectCategory()
- {
- ID = pro.RawID
- ,ProjectID = pro.ProjectID
- ,CategoryID = pro.CategoryID
-
- }).ToList();
- }
- });
- }
- #endregion
- }
-
- /// <summary>
- /// Dictionary Class
- /// </summary>
- public class Dictionary : ObjectBase
- {
- #region Properties
- /// <summary>
- /// ID field of Dictionary table
- /// </summary>
- public int ID { get; set; }
-
- /// <summary>
- /// Caption field of Dictionary table
- /// </summary>
- public string Caption { get; set; }
-
- /// <summary>
- /// Caption1 field of Dictionary table
- /// </summary>
- public string Caption1 { get; set; }
-
- /// <summary>
- /// CodeVal field of Dictionary table
- /// </summary>
- public int CodeVal { get; set; }
-
- /// <summary>
- /// ParentID field of Dictionary table
- /// </summary>
- public int ParentID { get; set; }
-
- /// <summary>
- /// DictionaryCode field of Dictionary table
- /// </summary>
- public int DictionaryCode { get; set; }
-
- /// <summary>
- /// SortValue field of Dictionary table
- /// </summary>
- public int SortValue { get; set; }
-
- /// <summary>
- /// Level field of Dictionary table
- /// </summary>
- public int Level { get; set; }
- #endregion
-
- /// <summary>
- /// Get List of Dictionary objects
- /// </summary>
- /// <param name="Level"></param>
- /// <param name="DictionaryCode"></param>
- /// <param name="ShowInvisibleItems"></param>
- /// <returns></returns>
- public List<Dictionary> ListDictionary(int? Level = null, int? DictionaryCode = null, bool? ShowInvisibleItems = null)
- {
- return TryToGetList<Dictionary>(string.Format("Core.Project.ListCategories: " +
- "Level {0}, DictionaryCode {1}, ShowInvisibleItems {2}", Level, DictionaryCode, ShowInvisibleItems), () =>
- {
- using (var db = ConnectionFactory.GetDBCoreDataContext())
- {
- return db.List_Dictionaries(Level, DictionaryCode, ShowInvisibleItems).Select(d => new Dictionary()
- {
- ID = d.DictionaryID
- ,Caption = d.Caption
- }).ToList();
- }
- });
- }
-
- /// <summary>
- /// Get DictionaryID by CodeVal
- /// </summary>
- /// <param name="DictionaryCode"></param>
- /// <param name="CodeVal"></param>
- /// <returns></returns>
- public int? GetDictionaryIDByCodeVal(int? DictionaryCode, int? CodeVal)
- {
- return TryToReturn<int?>(string.Format("Core.Dictionary.GetDictionaryIDByCodeVal: DictionaryCode {0}, CodeVal {1}", DictionaryCode, CodeVal), () =>
- {
- using (var db = ConnectionFactory.GetDBCoreDataContext())
- {
- return db.Get_DictionaryID_ByCodeVal(DictionaryCode, CodeVal);
- }
- });
- }
-
- }
-
- /// <summary>
- /// ProjectAssets Class
- /// </summary>
- public class ProjectAssets : ObjectBase
- {
- #region Properties
- /// <summary>
- /// ID field of ProjectAssets table
- /// </summary>
- public int? ID { get; set; }
- /// <summary>
- /// ProjectID field of ProjectAssets table
- /// </summary>
- public int ProjectID { get; set; }
- /// <summary>
- /// TypeID field of ProjectAssets table
- /// </summary>
- public int? TypeID { get; set; }
- /// <summary>
- /// CodeVal field of ProjectAssets table
- /// </summary>
- public int? CodeVal { get; set; }
- /// <summary>
- /// Position field of ProjectAssets table
- /// </summary>
- public int? Position { get; set; }
- /// <summary>
- /// Text field of ProjectAssets table
- /// </summary>
- public string Text { get; set; }
- /// <summary>
- /// Title field of ProjectAssets table
- /// </summary>
- public string Title { get; set; }
- /// <summary>
- /// Media field of ProjectAssets table
- /// </summary>
- public string Media { get; set; }
- /// <summary>
- /// Image file that is posted from form
- /// </summary>
- public HttpPostedFileBase imgFile { get; set; }
- #endregion
-
- #region Methods
- /// <summary>
- /// CRUD operation on ProjectAssets table
- /// </summary>
- /// <param name="Iud"></param>
- /// <param name="ProjectAssetsID"></param>
- /// <param name="ProjectID"></param>
- /// <param name="TypeID"></param>
- /// <param name="Position"></param>
- /// <param name="Text"></param>
- /// <param name="Title"></param>
- /// <param name="Media"></param>
- public void TSP_ProjectAssets(byte Iud, int? ProjectAssetsID, int? ProjectID, int? TypeID, int? Position, string Text, string Title, string Media)
- {
- TryExecute(string.Format("Core.Project.TSP_ProjectAssets: Iud {0}, ProjectAssetsID {1}, ProjectID {2}, TypeID {3}, Position {4}, Text {5}, Title {6}, Media {7} "
- , Iud, ProjectAssetsID, ProjectID, TypeID, Position, Text, Title, Media), () =>
- {
- using (var db = ConnectionFactory.GetDBCoreDataContext())
- {
- db.tsp_ProjectAssets(Iud, ref ProjectAssetsID, ProjectID, TypeID, Position, Text, Title, Media);
- ID = ProjectAssetsID;
- }
- });
- }
- /// <summary>
- /// Get list of ProjectAssets objects by ProjectID
- /// </summary>
- /// <param name="ProjectID"></param>
- /// <returns></returns>
- public List<ProjectAssets> ListProjectAssets(int? ProjectID)
- {
- return TryToGetList<ProjectAssets>(string.Format("Core.Project.ListProjectAssets: ProjectID {0}", ProjectID), () =>
- {
- using (var db = ConnectionFactory.GetDBCoreDataContext())
- {
- return db.List_PojectAssets(ProjectID).OrderBy(d => d.Position).Select(d => new ProjectAssets()
- {
- ID = d.ProjectAssetID
- ,ProjectID = d.ProjectID
- ,TypeID = d.TypeID
- ,Position = d.Position
- ,Text = d.Text
- ,Title = d.Title
- ,Media = d.Media
- ,CodeVal = d.CodeVal
- }).ToList();
- }
- });
- }
-
- /// <summary>
- /// Get new position for ProjectAssets
- /// </summary>
- /// <param name="ProjectID"></param>
- /// <returns></returns>
- public int? GetNewPosition(int ProjectID)
- {
- return TryToReturn<int?>(string.Format("Core.ProjectAssets.GetNewPosition: ProjectID {0}", ProjectID), () =>
- {
- using (var db = ConnectionFactory.GetDBCoreDataContext())
- {
- return db.Get_New_Position(ProjectID);
- }
- });
- }
- #endregion
- }
-
- /// <summary>
- /// People Class
- /// </summary>
- public class People : ObjectBase
- {
- #region Properties
- /// <summary>
- /// ID field of People table
- /// </summary>
- public int? ID { get; set; }
- /// <summary>
- /// PeopleName field of People table
- /// </summary>
- [Required(ErrorMessage = "Full Name is required")]
- public string PeopleName { get; set; }
- /// <summary>
- /// Position field of People table
- /// </summary>
- [DisplayFormat(ConvertEmptyStringToNull = false)]
- public string Position { get; set; }
- /// <summary>
- /// ImgName field of People table
- /// </summary>
- public string ImgName { get; set; }
- /// <summary>
- /// Image file that is posted from form
- /// </summary>
- public HttpPostedFileWrapper ImgFile { get; set; }
- /// <summary>
- /// MusicName field of People table
- /// </summary>
- public string MusicName { get; set; }
- /// <summary>
- /// Music file that is posted from form
- /// </summary>
- public HttpPostedFileWrapper MusicFile { get; set; }
- /// <summary>
- /// SortIndex field of People table
- /// </summary>
- public int? SortIndex { get; set; }
- /// <summary>
- /// Theme field of People table
- /// </summary>
- public string Theme { get; set; }
- /// <summary>
- /// IsPublished field of People table
- /// </summary>
- public bool? IsPublished { get; set; }
- /// <summary>
- /// Slug field of People table
- /// </summary>
- public string Slug { get; set; }
- /// <summary>
- /// List of People categories
- /// </summary>
- public List<int> PeopleCategories { get; set; }
- /// <summary>
- /// String of all Categories names
- /// </summary>
- public string CategoryNames { get; set; }
- #endregion
-
- #region Methods
- /// <summary>
- /// Get list of People objects
- /// </summary>
- /// <param name="Published"></param>
- /// <returns></returns>
- public List<People> ListPeoples(bool? Published)
- {
- return TryToGetList<People>(string.Format("Core.People.ListPeoples: Published {0}", Published), () =>
- {
- using (var db = ConnectionFactory.GetDBCoreDataContext())
- {
- return db.List_Peoples(Published).OrderBy(p => p.SortIndex).OrderByDescending(p => p.CRTime).Select(p => new People()
- {
- ID = p.PeopleID
- ,PeopleName = p.PeopleName
- ,Position = p.Position
- ,ImgName = p.ImgName
- ,MusicName = p.MusicName
- ,SortIndex = p.SortIndex
- ,Theme = p.Theme
- ,IsPublished = p.IsPublished
- ,Slug = p.Slug
- ,CategoryNames = p.Categories
-
- }).ToList();
- }
- });
- }
-
- /// <summary>
- /// CRUD opertion on Peoples table
- /// </summary>
- /// <param name="Iud"></param>
- /// <param name="_PeopleID"></param>
- /// <param name="_PeopleName"></param>
- /// <param name="_Position"></param>
- /// <param name="_ImgName"></param>
- /// <param name="_MusicName"></param>
- /// <param name="_SortIndex"></param>
- /// <param name="_Theme"></param>
- /// <param name="_IsPublished"></param>
- /// <param name="_Slug"></param>
- public void TSP_Peoples(byte Iud, int? _PeopleID, string _PeopleName, string _Position, string _ImgName, string _MusicName, int? _SortIndex, string _Theme, bool ? _IsPublished, string _Slug)
- {
- TryExecute(string.Format("Core.Project.TSP_ProjectAssets: " +
- "Iud {0}, PeopleID {1}, PeopleName {2}, Position {3}, ImgName {4}, MusicName {5}, SortIndex {6}, Theme {7}, IsPublished {8}, Slug {9}",
- Iud, _PeopleID, _PeopleName, _Position, _ImgName, _MusicName, _SortIndex, _Theme, _IsPublished, _Slug), () =>
- {
- using (var db = ConnectionFactory.GetDBCoreDataContext())
- {
- db.tsp_Peoples(Iud, ref _PeopleID, _PeopleName, _Position, _ImgName, _MusicName, _SortIndex, _Theme, _IsPublished, _Slug);
- }
- });
- }
- /// <summary>
- /// If Iud = 0 - Update People Table and delete/insert values in PeopleCategories table via PeopleID
- /// </summary>
- /// <param name="Iud"></param>
- /// <param name="Xml"></param>
- public void TX_Peoples(byte Iud, XElement Xml)
- {
- TryExecute(string.Format("Core.People.TX_Peoples"), () =>
- {
- using (var db = ConnectionFactory.GetDBCoreDataContext())
- {
- db.tx_Peoples(Iud, Xml);
- }
- });
- }
- /// <summary>
- /// Check if Slug is unique in Peoples table
- /// </summary>
- /// <param name="_Slug"></param>
- /// <returns></returns>
- public bool? IsSlugUniqueInPeoples(string _Slug)
- {
- return TryToReturn<bool?>(string.Format("Core.People.IsSlugUniqueInPeoples: Slug {0}", _Slug), () =>
- {
- using (var db = ConnectionFactory.GetDBCoreDataContext())
- {
- return db.IsSlugUniqueInPeoples(_Slug);
- }
- });
- }
- /// <summary>
- /// Get People object by Slug
- /// </summary>
- /// <param name="Slug"></param>
- public void GetPeopleBySlug(string Slug)
- {
- TryExecute(string.Format("Core.People.GetPeopleBySlug: Slug {0}", Slug), () =>
- {
- using (var db = ConnectionFactory.GetDBCoreDataContext())
- {
- XElement X = db.GetSinglePeopleBySlug(Slug);
-
- this.ID = X.IntValueOf("people_id");
- this.Position = X.ValueOf("position");
- this.ImgName = X.ValueOf("img_name");
- this.MusicName = X.ValueOf("music_name");
- this.SortIndex = X.IntValueOf("sort_index");
- this.Theme = X.ValueOf("theme");
- this.IsPublished = X.BooleanValueOf("is_published");
- this.Slug = X.ValueOf("slug");
- }
- });
- }
- #endregion
- }
-
- /// <summary>
- /// PeopleCategory Class
- /// </summary>
- public class PeopleCategory : ObjectBase
- {
- #region Properties
- /// <summary>
- /// ID field of PeopleCategory table
- /// </summary>
- public int ID { get; set; }
- /// <summary>
- /// PeopleID field of PeopleCategory table
- /// </summary>
- public int? PeopleID { get; set; }
- /// <summary>
- /// CategoryID field of PeopleCategory table
- /// </summary>
- public int? CategoryID { get; set; }
- #endregion
-
- #region Methods
- /// <summary>
- /// Get list of PeopleCategory objects
- /// </summary>
- /// <param name="PeopleID"></param>
- /// <returns></returns>
- public List<PeopleCategory> ListPeopleCategories(int PeopleID)
- {
- return TryToGetList<PeopleCategory>(string.Format("Core.PeopleCategory.ListPeopleCategories: PeopleID {0}", PeopleID), () =>
- {
- using (var db = ConnectionFactory.GetDBCoreDataContext())
- {
- return db.List_PeopleCategories(PeopleID).Select(pro => new PeopleCategory()
- {
- ID = pro.RawID
- ,
- PeopleID = pro.PeopleID
- ,
- CategoryID = pro.CategoryID
-
- }).ToList();
- }
- });
- }
- #endregion
- }
-
- /// <summary>
- /// FrontPage Class
- /// </summary>
- public class FrontPage : ObjectBase
- {
- #region Properties
- /// <summary>
- /// ID field of FrontPage table
- /// </summary>
- public int ID { get; set; }
- /// <summary>
- /// Name field of FrontPage table
- /// </summary>
- [Required(ErrorMessage = "Name is required")]
- public string Name { get; set; }
- /// <summary>
- /// Text field of FrontPage table
- /// </summary>
- [DisplayFormat(ConvertEmptyStringToNull = false)]
- public string Text { get; set; }
- /// <summary>
- /// ImageName field of FrontPage table
- /// </summary>
- public string ImageName { get; set; }
- /// <summary>
- /// Posted Image file
- /// </summary>
- public HttpPostedFileWrapper ImageFile { get; set; }
- /// <summary>
- /// Link field of FrontPage table
- /// </summary>
- [DisplayFormat(ConvertEmptyStringToNull = false)]
- public string Link { get; set; }
- /// <summary>
- /// SortIndex field of FrontPage table
- /// </summary>
- public int? SortIndex { get; set; }
- /// <summary>
- /// Theme field of FrontPage table
- /// </summary>
- [Required(ErrorMessage = "Theme is required")]
- public string Theme { get; set; }
- #endregion
-
- #region Methods
- /// <summary>
- /// Get list of FrontPage objects
- /// </summary>
- /// <returns></returns>
- public List<FrontPage> ListFrontPage()
- {
- return TryToGetList<FrontPage>(string.Format("Core.FrontPage.ListFrontPage"), () =>
- {
- using (var db = ConnectionFactory.GetDBCoreDataContext())
- {
- return db.List_FrontPage().OrderByDescending(f => f.CRTime).Select(f => new FrontPage()
- {
- ID = f.FrontPageID
- ,Name = f.Name
- ,Text = f.Text
- ,ImageName = f.ImageName
- ,Link = f.Link
- ,Theme = f.Theme
- }).ToList();
- }
- });
- }
- /// <summary>
- /// CRUD operation on FrontPage table
- /// </summary>
- /// <param name="Iud"></param>
- /// <param name="_FrontPageID"></param>
- /// <param name="_Name"></param>
- /// <param name="_Text"></param>
- /// <param name="_ImageName"></param>
- /// <param name="_Link"></param>
- /// <param name="_SortIndex"></param>
- /// <param name="_Theme"></param>
- public void TSP_FrontPage(byte Iud, int? _FrontPageID, string _Name, string _Text, string _ImageName, string _Link, int? _SortIndex, string _Theme)
- {
- TryExecute(string.Format("Core.FrontPage.TSP_FrontPage: " +
- "Iud {0}, FrontPageID {1}, Name {2}, Text {3}, ImageName {4}, Link {5}, SortIndex {6}, Theme {7}",
- Iud, _FrontPageID, _Name, _Text, _ImageName, _Link, _SortIndex, _Theme), () =>
- {
- using (var db = ConnectionFactory.GetDBCoreDataContext())
- {
- db.tsp_FrontPage(Iud, ref _FrontPageID, _Name, _Text, _ImageName, _Link, _SortIndex, _Theme);
- }
- });
- }
- #endregion
- }
-
- /// <summary>
- /// Client Class
- /// </summary>
- public class Client : ObjectBase
- {
- #region Properties
- /// <summary>
- /// ClientsID field of Clients table
- /// </summary>
- public int ID { get; set; }
- /// <summary>
- /// LogoName field of Clients table
- /// </summary>
- public string LogoName { get; set; }
- /// <summary>
- /// Posted Logo file
- /// </summary>
- public HttpPostedFileWrapper LogoFile { get; set; }
-
- /// <summary>
- /// SortIndex field of Clients table
- /// </summary>
- public int? SortIndex { get; set; }
- /// <summary>
- /// Link field of Clients table
- /// </summary>
- [DisplayFormat(ConvertEmptyStringToNull = false)]
- public string Link { get; set; }
- #endregion
-
- #region Methods
- /// <summary>
- /// Get list of Client objects
- /// </summary>
- /// <returns></returns>
- public List<Client> ListClients()
- {
- return TryToGetList<Client>(string.Format("Core.Client.ListClients"), () =>
- {
- using (var db = ConnectionFactory.GetDBCoreDataContext())
- {
- return db.List_Clients().OrderByDescending(f => f.CRTime).Select(c => new Client()
- {
- ID = c.ClientsID,
- LogoName = c.LogoName,
- SortIndex = c.SortIndex ,
- Link = c.Link
- }).ToList();
- }
- });
- }
- /// <summary>
- /// CRUD operations on Clients table
- /// </summary>
- /// <param name="Iud"></param>
- /// <param name="ClientsID"></param>
- /// <param name="LogoName"></param>
- /// <param name="SortIndex"></param>
- public void TSP_Clients(byte Iud, int? ClientsID, string LogoName, int? SortIndex, string Link)
- {
- TryExecute(string.Format("Core.Clients.TSP_Clients: " +
- "Iud {0}, ClientsID {1}, LogoName {2}, SortIndex {3}, Link {4} ",
- Iud, ClientsID, LogoName, SortIndex, Link), () =>
- {
- using (var db = ConnectionFactory.GetDBCoreDataContext())
- {
- db.tsp_Clients(Iud, ref ClientsID, LogoName, SortIndex, Link);
- }
- });
- }
- #endregion
- }
-
- public class About : ObjectBase
- {
- #region Properties
- /// <summary>
- /// AboutID field of About table
- /// </summary>
- public int ID { get; set; }
- /// <summary>
- /// CodeVal field of About table
- /// </summary>
- public int CodeVal { get; set; }
- /// <summary>
- /// BatterflyImage field of About table
- /// </summary>
- public string BatterflyImage { get; set; }
- /// <summary>
- /// DDBImage field of About table
- /// </summary>
- public string DDBImage { get; set; }
- /// <summary>
- /// BatterflyText field of About table
- /// </summary>
- [Required(ErrorMessage = "Text is required")]
- public string BatterflyText { get; set; }
- /// <summary>
- /// DDBText field of About table
- /// </summary>
- [Required(ErrorMessage = "Text is required")]
- public string DDBText { get; set; }
- #endregion
-
- #region Methods
- /// <summary>
- /// CRUD on About table
- /// </summary>
- /// <param name="Iud"></param>
- /// <param name="AboutID"></param>
- /// <param name="CodeVal"></param>
- /// <param name="BatterflyImage"></param>
- /// <param name="DDBImage"></param>
- /// <param name="BatterflyText"></param>
- /// <param name="DDBText"></param>
- public void TSP_About(byte Iud, int? AboutID, int? CodeVal, string BatterflyImage, string DDBImage, string BatterflyText, string DDBText)
- {
- TryExecute(string.Format("Core.About.TSP_About: " +
- "Iud {0}, AboutID {1}, CodeVal {2}, BatterflyImage {3}, DDBImage {4}, BatterflyText {5}, DDBText {6}",
- Iud, AboutID, CodeVal, BatterflyImage, DDBImage, BatterflyText, DDBText), () =>
- {
- using (var db = ConnectionFactory.GetDBCoreDataContext())
- {
- db.tsp_About(Iud, ref AboutID, CodeVal, BatterflyImage, DDBImage, BatterflyText, DDBText);
- }
- });
- }
-
- public About GetAbout()
- {
- return TryToReturn<About>(string.Format("Core.About.ListAbout"), () =>
- {
- using (var db = ConnectionFactory.GetDBCoreDataContext())
- {
- return db.Get_About().Select(f => new About()
- {
- ID = f.AboutID,
- CodeVal = f.CodeVal,
- BatterflyImage = f.BatterflyImage,
- DDBImage = f.DDBImage,
- BatterflyText = f.BatterflyText,
- DDBText = f.DDBText
- }).FirstOrDefault();
- }
- });
- }
-
- #endregion
- }
- public class Contact : ObjectBase
- {
- #region Properties
- /// <summary>
- /// ContactID field of Contact table
- /// </summary>
- public int ID { get; set; }
- /// <summary>
- /// CodeVal field of Contact table
- /// </summary>
- public int CodeVal { get; set; }
- /// <summary>
- /// ContactText field of Contact table
- /// </summary>
- public string ContactText { get; set; }
- #endregion
-
- #region Methods
- /// <summary>
- /// CRUD on Contact Table
- /// </summary>
- /// <param name="Iud"></param>
- /// <param name="ContactID"></param>
- /// <param name="CodeVal"></param>
- /// <param name="ContactText"></param>
- public void TSP_Contact(byte Iud, int? ContactID, int? CodeVal, string ContactText)
- {
- TryExecute(string.Format("Core.Contact.TSP_Contact: " +
- "Iud {0}, ContactID {1}, CodeVal {2}, ContactText {3}",
- Iud, ContactID, CodeVal, ContactText), () =>
- {
- using (var db = ConnectionFactory.GetDBCoreDataContext())
- {
- db.tsp_Contact(Iud, ref ContactID, CodeVal, ContactText);
- }
- });
- }
- public Contact GetContact()
- {
- return TryToReturn<Contact>(string.Format("Core.Contact.GetContact"), () =>
- {
- using (var db = ConnectionFactory.GetDBCoreDataContext())
- {
- return db.Get_Contact().Select(f => new Contact()
- {
- ID = f.ContactID,
- CodeVal = f.CodeVal,
- ContactText = f.ContactText
- }).FirstOrDefault();
- }
- });
- }
- #endregion
- }
- }