Example #1
0
        //用于修改文章
        public static BaseResultModel <Article> UpdateArticle(Article article)
        {
            BaseResultModel <Article> result = new BaseResultModel <Article>();

            try{
                using (CDBContext _cDBContext = new CDBContext()){
                    Article a = _cDBContext.Ar.FirstOrDefault(p => p.Id.Equals(article.Id));
                    a.UserName       = article.UserName;
                    a.type           = article.type;
                    a.ArticleContext = article.ArticleContext;

                    a.ArticleSideName   = article.ArticleSideName;
                    a.ArticleUpdateDate = article.ArticleUpdateDate;
                    a.ArticleName       = article.ArticleName;
                    _cDBContext.Ar.Update(a);
                    _cDBContext.SaveChanges();

                    result.status  = 1;
                    result.Data    = null;
                    result.message = "更新文章成功!";
                }
            }catch (Exception ex) {
                result.status  = 0;
                result.Data    = null;
                result.message = ex.ToString();
            }
            return(result);
        }
Example #2
0
        //用于添加富文章
        public static BaseResultModel <SimpleArticle> SetRichArticle(SimpleArticle simpleArticle)
        {
            BaseResultModel <SimpleArticle> result = new BaseResultModel <SimpleArticle>();

            try{
                using (CDBContext _cDBContext = new CDBContext()){
                    SimpleArticle a = new SimpleArticle();
                    a.UserName          = simpleArticle.UserName;
                    a.type              = simpleArticle.type;
                    a.ArticleContext    = simpleArticle.ArticleContext;
                    a.ArticleCreateDate = simpleArticle.ArticleCreateDate;
                    a.ArticleImgUrl     = simpleArticle.ArticleImgUrl;
                    a.ArticleUpdateDate = simpleArticle.ArticleUpdateDate;
                    _cDBContext.Si.Add(a);
                    _cDBContext.SaveChanges();

                    result.status  = 1;
                    result.Data    = null;
                    result.message = "添加文章成功!";
                }
            }catch (Exception ex) {
                result.status  = 0;
                result.Data    = null;
                result.message = ex.ToString();
            }
            return(result);
        }
Example #3
0
        public void Guardar()
        {
            //var docente = new Docente();

            try
            {
                using (CDBContext db = new CDBContext())
                {
                    if (this.Code_Docente == 0)
                    {
                        db.Entry(this).State = EntityState.Added;
                        foreach (var m in this.Materias)
                        {
                            db.Entry(m).State = EntityState.Unchanged;
                        }
                    }
                    db.SaveChanges();
                }
            }

            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Example #4
0
        //一次添加多个轮播图
        public static BaseResultModel <List <ScrollPicture> > AddScrollPicList(List <ScrollPicture> sp)
        {
            BaseResultModel <List <ScrollPicture> > result = new BaseResultModel <List <ScrollPicture> >();

            try{
                using (CDBContext _cDBContext = new CDBContext()){
                    for (int i = 0; i < sp.Count; i++)
                    {
                        ScrollPicture scrollpicture = new ScrollPicture();
                        scrollpicture.PicName       = sp[i].PicName;
                        scrollpicture.ImgUrl        = sp[i].ImgUrl;
                        scrollpicture.ImgSubmitDate = sp[i].ImgSubmitDate;
                        scrollpicture.UserName      = sp[i].UserName;
                        _cDBContext.Sc.Add(scrollpicture);
                    }
                    _cDBContext.SaveChanges();
                    result.status  = 1;
                    result.Data    = null;
                    result.message = "多张轮播图添加成功";
                }
            }catch (Exception ex) {
                result.status  = 0;
                result.Data    = null;
                result.message = ex.ToString();
            }
            return(result);
        }
Example #5
0
        //添加邮件信息
        public static BaseResultModel <Message> SetMail(Message message)
        {
            BaseResultModel <Message> result = new BaseResultModel <Message>();

            try{
                using (CDBContext _cDBContext = new CDBContext()){
                    Message ms = new Message();
                    ms.Name       = message.Name;
                    ms.Phone      = message.Phone;
                    ms.Email      = message.Email;
                    ms.Infos      = message.Infos;
                    ms.SubmitDate = DateTime.Now.ToString();
                    _cDBContext.Me.Add(ms);
                    _cDBContext.SaveChanges();
                    result.status  = 1;
                    result.Data    = ms;
                    result.message = "邮件提交成功!";
                }
            }catch (Exception ex) {
                result.status  = 0;
                result.Data    = null;
                result.message = ex.ToString();
            }
            return(result);
        }
Example #6
0
        static void Main(string[] args)
        {
            CMysqlDBContext K = new CMysqlDBContext();

            var list = K.userInfos.ToList();

            K.Dispose();

            CDBContext dBContext = new CDBContext();


            var listUser = dBContext.userInfos.ToList();
        }
Example #7
0
        //用于获取不同页面中富文本介绍
        public static BaseResultModel <List <SimpleArticle> > GetFrontRichList(string type)
        {
            BaseResultModel <List <SimpleArticle> > result = new BaseResultModel <List <SimpleArticle> >();

            try{
                using (CDBContext _cDBContext = new CDBContext()){
                    result.status  = 1;
                    result.Data    = _cDBContext.Si.Where(p => p.type.Equals(type)).Take(3).ToList();
                    result.message = "获取数据成功!";
                }
            }catch (Exception ex) {
                result.status  = 0;
                result.Data    = null;
                result.message = ex.ToString();
            }
            return(result);
        }
Example #8
0
        //前台根据页面获取文章列表
        public static BaseResultModel <List <Article> > GetFrontArticleList(string type)
        {
            BaseResultModel <List <Article> > result = new BaseResultModel <List <Article> >();

            try{
                using (CDBContext _cDBContext = new CDBContext()){
                    List <Article> messages = _cDBContext.Ar.Where(p => p.type == type).Take(3).ToList();
                    result.status  = 1;
                    result.Data    = messages;
                    result.message = "获取数据成功!";
                }
            }catch (Exception ex) {
                result.status  = 0;
                result.Data    = null;
                result.message = ex.ToString();
            }
            return(result);
        }
Example #9
0
        //前台根据页面获取页面左下角图文
        public static BaseResultModel <Article> GetFrontArticle(string type)
        {
            BaseResultModel <Article> result = new BaseResultModel <Article>();

            try{
                using (CDBContext _cDBContext = new CDBContext()){
                    Article messages = _cDBContext.Ar.FirstOrDefault(p => p.type == type);
                    result.status  = 1;
                    result.Data    = messages;
                    result.message = "获取数据成功!";
                }
            }catch (Exception ex) {
                result.status  = 0;
                result.Data    = null;
                result.message = ex.ToString();
            }
            return(result);
        }
Example #10
0
        public List <Docente> allDocentes()
        {
            var docente = new List <Docente>();

            try
            {
                using (CDBContext db = new CDBContext())
                {
                    docente = db.Docentes.ToList();
                }
            }

            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            return(docente);
        }
Example #11
0
        public List <Materia> allMaterias()
        {
            var materias = new List <Materia>();

            try
            {
                using (CDBContext db = new CDBContext())
                {
                    materias = db.Materias.ToList();
                }
            }

            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            return(materias);
        }
Example #12
0
        //后台获取文章类型
        public static PaginationResultModel <Article> GetArticleList(PaginationModel pageList)
        {
            PaginationResultModel <Article> result = new PaginationResultModel <Article>();

            try{
                using (CDBContext _cDBContext = new CDBContext()){
                    List <Article> messages = _cDBContext.Ar.Skip((pageList.Index - 1) * pageList.Size).Take(pageList.Size).ToList();
                    result.Total   = _cDBContext.Ar.Count();
                    result.status  = 1;
                    result.Data    = messages;
                    result.message = "获取数据成功!";
                }
            }catch (Exception ex) {
                result.status  = 0;
                result.Data    = null;
                result.message = ex.ToString();
                result.Total   = 0;
            }
            return(result);
        }
Example #13
0
        // private static CDBContext _cDBContext;
        // public MailService(CDBContext CDBContext){
        //    _cDBContext=CDBContext;
        // }
        //展示邮件列表
        public static PaginationResultModel <Message> GetMailList(PaginationModel pageList)
        {
            PaginationResultModel <Message> result = new PaginationResultModel <Message>();

            try{
                using (CDBContext cb = new CDBContext()){
                    List <Message> mss = new List <Message>();
                    mss            = cb.Me.Skip((pageList.Index - 1) * pageList.Size).Take(pageList.Size).ToList();
                    result.Total   = cb.Me.Count();
                    result.status  = 1;
                    result.Data    = mss;
                    result.message = "获取数据成功!";
                }
            }catch (Exception ex) {
                result.status  = 0;
                result.Data    = null;
                result.message = ex.ToString();
                result.Total   = 0;
            }
            return(result);
        }
Example #14
0
        public static PaginationResultModel <ScrollPicture> GetPicList(PaginationModel pageList)
        {
            PaginationResultModel <ScrollPicture> result = new  PaginationResultModel <ScrollPicture>();

            try{
                using (CDBContext _cDBContext = new CDBContext()){
                    List <ScrollPicture> sps = new List <ScrollPicture>();
                    sps            = _cDBContext.Sc.Skip((pageList.Index - 1) * pageList.Size).Take(pageList.Size).ToList();
                    result.Total   = _cDBContext.Sc.Count();
                    result.status  = 1;
                    result.Data    = sps;
                    result.message = "获取轮播图添加成功";
                }
            }catch (Exception ex) {
                result.status  = 0;
                result.Data    = null;
                result.message = ex.ToString();
                result.Total   = 0;
            }
            return(result);
        }
Example #15
0
        public Docente getConsulta(int id)
        {
            var docente = new Docente();

            try
            {
                using (CDBContext db = new CDBContext())
                {
                    docente = db.Docentes
                              .Include("Materia")
                              .Where(x => x.Code_Docente == id)
                              .Single();
                }
            }

            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            return(docente);
        }
Example #16
0
        public static BaseResultModel <ScrollPicture> DeleteScrollPic(string Id)
        {
            int id = Int32.Parse(Id);
            BaseResultModel <ScrollPicture> result = new BaseResultModel <ScrollPicture>();

            try{
                using (CDBContext _cDBContext = new CDBContext()){
                    ScrollPicture sps = new ScrollPicture();
                    sps = _cDBContext.Sc.FirstOrDefault(p => p.Id == id);
                    _cDBContext.Remove(sps);
                    _cDBContext.SaveChanges();
                    result.status  = 1;
                    result.Data    = null;
                    result.message = "删除轮播图添加成功";
                }
            }catch (Exception ex) {
                result.status  = 0;
                result.Data    = null;
                result.message = ex.ToString();
            }
            return(result);
        }
Example #17
0
        public static BaseResultModel <Message> DeleteMessages(string Id)
        {
            int id = Int32.Parse(Id);
            BaseResultModel <Message> result = new BaseResultModel <Message>();

            try{
                using (CDBContext _cDBContext = new CDBContext()){
                    Message ms = new Message();
                    ms = _cDBContext.Me.FirstOrDefault(p => p.Id == id);
                    _cDBContext.Remove(ms);
                    _cDBContext.SaveChanges();
                    result.status  = 1;
                    result.Data    = null;
                    result.message = "邮件删除成功!";
                }
            }catch (Exception ex) {
                result.status  = 0;
                result.Data    = null;
                result.message = ex.ToString();
            }
            return(result);
        }
Example #18
0
        //用于修改富文章
        public static BaseResultModel <SimpleArticle> UpdateRichArticle(SimpleArticle simpleArticle)
        {
            BaseResultModel <SimpleArticle> result = new BaseResultModel <SimpleArticle>();

            try{
                using (CDBContext _cDBContext = new CDBContext()){
                    SimpleArticle a = _cDBContext.Si.FirstOrDefault(p => p.Id == simpleArticle.Id);
                    a.UserName          = simpleArticle.UserName;
                    a.type              = simpleArticle.type;
                    a.ArticleContext    = simpleArticle.ArticleContext;
                    a.ArticleUpdateDate = simpleArticle.ArticleUpdateDate;
                    _cDBContext.Si.Update(a);
                    _cDBContext.SaveChanges();
                    result.status  = 1;
                    result.Data    = null;
                    result.message = "更新文章成功!";
                }
            }catch (Exception ex) {
                result.status  = 0;
                result.Data    = null;
                result.message = ex.ToString();
            }
            return(result);
        }
Example #19
0
        //添加轮播图片
        public static BaseResultModel <ScrollPicture> AddScrollPic(ScrollPicture sp)
        {
            BaseResultModel <ScrollPicture> result = new BaseResultModel <ScrollPicture>();

            try{
                using (CDBContext _cDBContext = new CDBContext()){
                    ScrollPicture scrollpicture = new ScrollPicture();
                    scrollpicture.PicName       = sp.PicName;
                    scrollpicture.ImgUrl        = sp.ImgUrl;
                    scrollpicture.ImgSubmitDate = sp.ImgSubmitDate;
                    scrollpicture.UserName      = sp.UserName;
                    _cDBContext.Sc.Add(scrollpicture);
                    _cDBContext.SaveChanges();
                    result.status  = 1;
                    result.Data    = null;
                    result.message = "轮播图添加成功";
                }
            }catch (Exception ex) {
                result.status  = 0;
                result.Data    = null;
                result.message = ex.ToString();
            }
            return(result);
        }
Example #20
0
 public CustomersController()
 {
     _db = new CDBContext();
     GeneraToken();
 }
 public HomeController()
 {
     _context = new CDBContext();
 }
Example #22
0
 public ScrollPicService(CDBContext CDBContext)
 {
     _cDBContext = CDBContext;
 }