Exemplo n.º 1
0
 public bool RegisterUser(UserRegisterDTO register)
 {
     try
     {
         using (StoryboardDBEntities context = new StoryboardDBEntities())
         {
             context.Users.Add(new User()
             {
                 FirstName  = register.FirstName,
                 MiddleName = register.MiddleName,
                 LastName   = register.LastName,
                 Email      = register.Email,
                 Password   = register.Password,
                 CreatedOn  = DateTime.Now,
                 ModifiedOn = DateTime.Now
             });
             context.SaveChanges();
             return(true);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 2
0
        public bool UpdatePost(ArticleDTO data)
        {
            try
            {
                using (StoryboardDBEntities context = new StoryboardDBEntities())
                {
                    Article article = context.Articles.Where(x => x.Id == data.Id && x.IsDeleted == false).FirstOrDefault();
                    if (article != null)
                    {
                        article.Title       = data.Title;
                        article.ShortDesc   = data.ShortDesc;
                        article.Tags        = data.Tags;
                        article.ArticleDesc = data.ArticleDesc;
                        article.ModifiedOn  = DateTime.Now;

                        context.Entry(article).State = EntityState.Modified;
                        context.SaveChanges();
                    }


                    return(true);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 3
0
        public bool DeletePost(int articleId)
        {
            try
            {
                using (StoryboardDBEntities context = new StoryboardDBEntities())
                {
                    Article article = context.Articles.Where(x => x.Id == articleId && x.IsDeleted == false).FirstOrDefault();
                    if (article != null)
                    {
                        article.IsDeleted  = true;
                        article.ModifiedOn = DateTime.Now;


                        context.Entry(article).State = EntityState.Modified;
                        context.SaveChanges();
                    }
                    return(true);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 4
0
 public bool CreatePost(ArticleDTO data)
 {
     try
     {
         using (StoryboardDBEntities context = new StoryboardDBEntities())
         {
             context.Articles.Add(new Article()
             {
                 Title       = data.Title,
                 ShortDesc   = data.ShortDesc,
                 Tags        = data.Tags,
                 ArticleDesc = data.ArticleDesc,
                 CreatedOn   = DateTime.Now,
                 ModifiedOn  = DateTime.Now
             });
             context.SaveChanges();
             return(true);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }