Example #1
0
        public Author getAuthor(int id)
        {
            using (var ctx = new Models.Model())
            {
                Models.Author a  = ctx.authors.FirstOrDefault(x => x.authorId == id);
                Author        a1 = new Author();

                a1.authorId    = a.authorId;
                a1.authorName  = a.authorName;
                a1.authorImage = a.authorImage;
                a1.imagedata   = getImage(a.authorImage);
                a1.authorCity  = a.authorCity;
                return(a1);
            }
        }
Example #2
0
        public int addAuthor(Author a)
        {
            using (var ctx = new Models.Model())
            {
                Models.Author a1 = new Models.Author();
                a1.authorName = a.authorName;

                a1.password    = a.password;
                a1.authorImage = a.authorImage;
                a1.authorCity  = a.authorCity;
                bool flag = uploadImage(a.imagedata, a.authorImage);
                ctx.authors.Add(a1);
                ctx.SaveChanges();
                //System.Diagnostics.Debug.WriteLine("Author ID &&&&"+a1.authorId);
                return(a1.authorId);
            }
        }
Example #3
0
        /*======================================================================*/

        public Author Login(string authorname, string password)
        {
            using (var ctx = new Models.Model())
            {
                Author a1 = new Author();


                Models.Author a = ctx.authors.FirstOrDefault(x => x.password == password && x.authorName == authorname);

                a1.authorId    = a.authorId;
                a1.authorName  = a.authorName;
                a1.authorImage = a.authorImage;
                a1.authorCity  = a.authorCity;
                a1.imagedata   = getImage(a.authorImage);


                return(a1);
            }
        }
Example #4
0
        public int addNews(News n)
        {
            using (var ctx = new Models.Model())
            {
                Models.News n1 = new Models.News();
                n1.title       = n.title;
                n1.description = n.description;
                n1.datetime    = DateTime.Now;
                n1.tag         = n.tag;
                n1.newsCity    = n.newsCity;
                n1.image       = n.image;

                bool flag = uploadImage(n.imagedata, n.image);

                Models.Author a = ctx.authors.FirstOrDefault(x => x.authorId == n.author.authorId);
                n1.author = a;
                ctx.news.Add(n1);
                ctx.SaveChanges();
                return(n1.newsId);
            }
        }
Example #5
0
 public Author updateAuthor(Author a)
 {
     using (var ctx = new Models.Model())
     {
         Models.Author a1 = ctx.authors.FirstOrDefault(x => x.authorId == a.authorId);
         a1.authorId = a.authorId;
         if (a.authorName != null)
         {
             a1.authorName = a.authorName;
         }
         if (a.authorImage != null)
         {
             a1.authorImage = a.authorImage;
         }
         if (a.authorCity != null)
         {
             a1.authorCity = a.authorCity;
         }
         bool flag = uploadImage(a.imagedata, a.authorImage);
         ctx.SaveChanges();
         return(a);
     }
 }