public MainWindow()
        {
            InitializeComponent();

            websiteContext          = new WebSiteContext();
            cancellationTokenSource = new CancellationTokenSource();
        }
Esempio n. 2
0
 public void Initialize()
 {
     var connection = DbConnectionFactory.CreateTransient() as System.Data.Common.DbConnection;
     _context = new WebSiteContext(connection);
     IUnitOfWork _uow = new UnitOfWork<WebSiteContext>(_context);
     _repository = new BannerRepository(_uow);
 }
Esempio n. 3
0
        public IList <BlogEntryModel> GetAll()
        {
            var blogs = new List <BlogEntryModel>();

            try
            {
                using (WebSiteContext db = new WebSiteContext())
                {
                    var dbBblogEntries = db.BlogEntries.ToList();
                    foreach (BlogEntry blog in dbBblogEntries)
                    {
                        blogs.Add(new BlogEntryModel()
                        {
                            BlogName = blog.Blog.BlogName,
                            BlogId   = blog.Id.ToString(),
                            Id       = blog.Id,
                            Title    = blog.Title,
                            Created  = blog.Created.ToShortDateString(),
                            Color    = blog.Blog.Color
                        });
                    }
                }
            }
            catch (Exception ex) { blogs.Add(new BlogEntryModel()
                {
                    Title = Helpers.ErrorDetails(ex)
                }); }
            return(blogs);
        }
Esempio n. 4
0
        public string Post(ListItemModel newItem)
        {
            var success = "";

            try
            {
                ListItem listItem = new ListItem()
                {
                    ListId          = newItem.ListId,
                    Id              = Guid.NewGuid().ToString(),
                    ParentId        = newItem.ParentId,
                    ItemName        = newItem.ItemName,
                    AssignedTo      = newItem.AssignedTo,
                    ItemPriorityRef = newItem.ItemPriorityRef,
                    ItemStatusRef   = newItem.ItemStatusRef,
                    PercentComplete = newItem.PercentComplete,
                    Narrative       = newItem.Narrative,
                    Created         = DateTime.Now
                };

                using (WebSiteContext db = new WebSiteContext())
                {
                    db.ListItems.Add(listItem);
                    db.SaveChanges();
                    success = listItem.Id;
                }
            }
            catch (Exception ex) { success = Helpers.ErrorDetails(ex); }
            return(success);
        }
Esempio n. 5
0
        public string Put(Comment updateComment)
        {
            string success = "";

            try
            {
                using (WebSiteContext db = new WebSiteContext())
                {
                    Comment comment = db.Comments.Where(c => c.CommentId == updateComment.CommentId).FirstOrDefault();
                    if (comment != null)
                    {
                        comment.CommentText  = updateComment.CommentText;
                        comment.CommentTitle = updateComment.CommentTitle;

                        db.SaveChanges();
                        success = "ok";
                    }
                    else
                    {
                        success = "comment not found";
                    }
                }
            }
            catch (Exception ex)
            {
                success = Helpers.ErrorDetails(ex);
            }
            return(success);
        }
Esempio n. 6
0
        public string Put(ArticleModel editArticle)
        {
            var success = "";

            try
            {
                using (WebSiteContext db = new WebSiteContext())
                {
                    Article article = db.Articles.Where(a => a.Id.ToString() == editArticle.Id).FirstOrDefault();
                    article.Title          = editArticle.Title;
                    article.CategoryRef    = editArticle.CategoryRef;
                    article.SubCategoryRef = editArticle.SubCategoryRef;
                    article.ImageName      = editArticle.ImageName;
                    article.LastUpdated    = DateTime.Parse(editArticle.LastUpdated);
                    article.ByLineRef      = editArticle.ByLineRef;
                    article.Content        = editArticle.Contents;
                    article.Summary        = editArticle.Summary;

                    db.ArticleTags.RemoveRange(db.ArticleTags.Where(t => t.articleId.ToString() == editArticle.Id));
                    //article.ArticleTags = null;
                    foreach (DbArticleTagModel tagModel in editArticle.Tags)
                    {
                        article.ArticleTags.Add(new ArticleTag()
                        {
                            articleId = article.Id, Id = tagModel.Id, TagName = tagModel.TagName
                        });
                    }

                    db.SaveChanges();
                    success = "ok";
                }
            }
            catch (Exception ex) { success = Helpers.ErrorDetails(ex); }
            return(success);
        }
Esempio n. 7
0
        private void Form1_Load(object sender, EventArgs e)
        {
            this.Log = new List <string>();
            Control.CheckForIllegalCrossThreadCalls = false;
            this.AddLog("Program loading...");

            this.AddLog("Keywords loading...");
            KeywordContext.Load();
            this.AddLog("WebSites loading...");
            WebSiteContext.Load();
            this.UpdateKeywordList();
            this.AddLog("UI Components loading...");
            this.LoadDataGrids();
            this.AddLog("Bot settings are loaded, Bot is diseabled!");
            this.BotIsActive = false;


            cbWebSite.DataSource    = WebSiteContext.Sites;
            cbWebSite.DisplayMember = "Name";
            cbWebSite.ValueMember   = "Id";

            cbBotStatus.DataSource = Enum.GetValues(typeof(BotStatusEnum));

            BotTimer.Interval = 15000;
            BotTimer.Tick    += new EventHandler(timer_Tick);
            BotTimer.Start();

            this.AddLog("Program succesfully loaded!");
        }
Esempio n. 8
0
            private static MenuRoleModel[] GetMenuRole()
            {
                var objectCache = MemoryCache.Default;

                if (!objectCache.Contains("MenuRole"))
                {
                    var db        = new WebSiteContext();
                    var menuRoles = db.Menus.Include("Roles")
                                    .Where(m => !string.IsNullOrEmpty(m.Controller)) //&& !string.IsNullOrEmpty(m.Action))
                                    .ToArray()
                                    .Select(m => new MenuRoleModel
                    {
                        Controller = m.Controller,
                        Action     = m.Action,
                        Roles      = m.Roles.Select(r => r.Name).ToArray()
                    })
                                    .ToArray();
                    objectCache.Add("MenuRole", menuRoles,
                                    new CacheItemPolicy()
                    {
                        AbsoluteExpiration = DateTimeOffset.Now.AddDays(1)
                    });
                }

                MenuRoleModel[] roles = objectCache["MenuRole"] as MenuRoleModel[];
                return(roles);
            }
Esempio n. 9
0
        public string Put(BlogModel editBlog)
        {
            var success = "";

            try
            {
                using (WebSiteContext db = new WebSiteContext())
                {
                    Blog blog = db.Blogs.Where(b => b.Id.ToString() == editBlog.Id).FirstOrDefault();
                    if (blog == null)
                    {
                        success = "article not found";
                    }
                    else
                    {
                        blog.BlogName  = editBlog.Name;
                        blog.Color     = editBlog.Color;
                        blog.BlogOwner = editBlog.Owner;
                        db.SaveChanges();
                        success = "ok";
                    }
                }
            }
            catch (Exception ex) { success = Helpers.ErrorDetails(ex); }
            return(success);
        }
Esempio n. 10
0
        public string Put(ListItemModel editItem)
        {
            var success = "";

            try
            {
                using (WebSiteContext db = new WebSiteContext())
                {
                    ListItem listItem = db.ListItems.Where(i => i.Id == editItem.Id).FirstOrDefault();
                    if (listItem == null)
                    {
                        success = "listItem not found";
                    }
                    else
                    {
                        listItem.ParentId        = editItem.ParentId;
                        listItem.ItemName        = editItem.ItemName;
                        listItem.ItemPriorityRef = editItem.ItemPriorityRef;
                        listItem.ItemStatusRef   = editItem.ItemStatusRef;
                        listItem.AssignedTo      = editItem.AssignedTo;
                        listItem.PercentComplete = editItem.PercentComplete;
                        listItem.Narrative       = editItem.Narrative;
                        if (editItem.DateCompleted != null)
                        {
                            listItem.DateCompleted = DateTime.Parse(editItem.DateCompleted);
                        }

                        db.SaveChanges();
                        success = "ok";
                    }
                }
            }
            catch (Exception ex) { success = Helpers.ErrorDetails(ex); }
            return(success);
        }
Esempio n. 11
0
        public IList <ListItemModel> GetMany(string listId)
        {
            var listItems = new List <ListItemModel>();

            try
            {
                using (WebSiteContext db = new WebSiteContext())
                {
                    var dbListItems = db.ListItems.Where(l => l.ListId == listId).ToList();
                    foreach (ListItem listItem in dbListItems)
                    {
                        listItems.Add(new ListItemModel()
                        {
                            Id       = listItem.Id,
                            ItemName = listItem.ItemName
                        });
                    }
                }
            }
            catch (Exception ex) { listItems.Add(new ListItemModel()
                {
                    ItemName = Helpers.ErrorDetails(ex)
                }); }
            return(listItems);
        }
Esempio n. 12
0
        public CommentsModel Post(CommentsModel newComment)
        {
            try
            {
                using (WebSiteContext db = new WebSiteContext())
                {
                    var comment = new Comment();
                    comment.CreateDate   = DateTime.Now;
                    comment.ArticleId    = newComment.ArticleId;
                    comment.CommentText  = newComment.CommentText;
                    comment.CommentTitle = newComment.CommentTitle;
                    comment.UserId       = newComment.UserId;
                    comment.UserName     = newComment.UserName;
                    db.Comments.Add(comment);
                    db.SaveChanges();

                    newComment.CommentId  = comment.CommentId;
                    newComment.CreateDate = comment.CreateDate.ToShortDateString();
                    newComment.success    = "ok";

                    newComment.success = new GodaddyEmailController().SendEmail("Somebody Actually Made A comment", comment.UserName + " said: " + comment.CommentText);
                }
            }
            catch (Exception ex)
            {
                newComment.success = Helpers.ErrorDetails(ex);
            }
            return(newComment);
        }
Esempio n. 13
0
        public IList <BlogModel> GetMany()
        {
            var blogs = new List <BlogModel>();

            try
            {
                using (WebSiteContext db = new WebSiteContext())
                {
                    var dbBblogs = db.Blogs.ToList();
                    foreach (Blog blog in dbBblogs)
                    {
                        blogs.Add(new BlogModel()
                        {
                            Id    = blog.Id.ToString(),
                            Name  = blog.BlogName,
                            Color = blog.Color,
                            Owner = blog.BlogOwner
                        });
                    }
                }
            }
            catch (Exception ex) { blogs.Add(new BlogModel()
                {
                    Name = Helpers.ErrorDetails(ex)
                }); }
            return(blogs);
        }
Esempio n. 14
0
        public IList <ListModel> GetMany()
        {
            var lists = new List <ListModel>();

            try
            {
                using (WebSiteContext db = new WebSiteContext())
                {
                    var dbLists = db.Lists.ToList();
                    foreach (ToDoList list in dbLists)
                    {
                        lists.Add(new ListModel()
                        {
                            Id        = list.Id,
                            ListName  = list.ListName,
                            ListOwner = list.ListOwner,
                            Created   = list.Created.ToShortDateString()
                        });
                    }
                }
            }
            catch (Exception ex) { lists.Add(new ListModel()
                {
                    ListName = Helpers.ErrorDetails(ex)
                }); }
            return(lists);
        }
Esempio n. 15
0
        public string Put(BlogEntryModel editBlogEntry)
        {
            var success = "";

            try
            {
                using (WebSiteContext db = new WebSiteContext())
                {
                    BlogEntry blogEntry = db.BlogEntries.Where(b => b.Id.ToString() == editBlogEntry.Id).FirstOrDefault();
                    if (blogEntry == null)
                    {
                        success = "article not found";
                    }
                    else
                    {
                        blogEntry.Title       = editBlogEntry.Title;
                        blogEntry.ImageName   = editBlogEntry.ImageName;
                        blogEntry.Summary     = editBlogEntry.Summary;
                        blogEntry.Content     = editBlogEntry.Content;
                        blogEntry.LastUpdated = DateTime.Now;
                        db.SaveChanges();
                        success = "ok";
                    }
                }
            }
            catch (Exception ex) { success = Helpers.ErrorDetails(ex); }
            return(success);
        }
Esempio n. 16
0
        public string Post(BlogEntryModel newBlogEntry)
        {
            var success = "";

            try
            {
                BlogEntry blogEntry = new BlogEntry();
                blogEntry.BlogId      = newBlogEntry.BlogId;
                blogEntry.Id          = Guid.NewGuid().ToString();
                blogEntry.Title       = newBlogEntry.Title;
                blogEntry.ImageName   = newBlogEntry.ImageName;
                blogEntry.Summary     = newBlogEntry.Summary;
                blogEntry.Content     = newBlogEntry.Content;
                blogEntry.Created     = DateTime.Now;
                blogEntry.LastUpdated = DateTime.Now;

                using (WebSiteContext db = new WebSiteContext())
                {
                    db.BlogEntries.Add(blogEntry);
                    db.SaveChanges();
                    success = blogEntry.Id.ToString();
                }
            }
            catch (Exception ex) { success = Helpers.ErrorDetails(ex); }
            return(success);
        }
 public static void Init()
 {
     using (var dbcontext = new WebSiteContext())
     {
         var objectContext     = ((IObjectContextAdapter)dbcontext).ObjectContext;
         var mappingCollection = (StorageMappingItemCollection)objectContext.MetadataWorkspace.GetItemCollection(DataSpace.CSSpace);
         mappingCollection.GenerateViews(new List <EdmSchemaError>());
     }
 }
Esempio n. 18
0
        public void Initialize()
        {
            var connection = DbConnectionFactory.CreateTransient() as System.Data.Common.DbConnection;

            _context = new WebSiteContext(connection);
            IUnitOfWork _uow = new UnitOfWork <WebSiteContext>(_context);

            _repository = new BannerRepository(_uow);
        }
Esempio n. 19
0
        private void btnTest_Click(object sender, EventArgs e)
        {
            if (cbWebSite.SelectedItem == null || txtURL.Text == "" || WebSiteContext.GetModel(((WebSiteModel)cbWebSite.SelectedItem).Id) == null)
            {
                MessageBox.Show("Lutfen gerekli alanlari oldurun!", "Uyari", MessageBoxButtons.OK);
                return;
            }

            if (DataContext.IsSearchPointExist(txtURL.Text))
            {
                MessageBox.Show("Ilan hali hazirlda kayitli!", "Uyari", MessageBoxButtons.OK);
                return;
            }

            WebSiteModel site = (WebSiteModel)cbWebSite.SelectedItem;

            switch (site.Id)
            {
            case 1:
                Rec = SC.HPScanAd(txtURL.Text);
                break;

            case 2:
                Rec = SC.N11ScanAd(txtURL.Text);
                break;

            default:
                break;
            }

            if (Rec == null)
            {
                lblTestStatus.ForeColor = Color.Red;
                lblTestStatus.Text      = "Operation failed!";
                btnAdd.Enabled          = false;
            }
            else
            {
                if (txtName.Text != "")
                {
                    string tempText = txtName.Text;
                    FillForm();
                    txtName.Text = tempText;
                    Rec.Name     = tempText;
                }
                else
                {
                    FillForm();
                }

                lblTestStatus.ForeColor = Color.Green;
                lblTestStatus.Text      = "Operation succecful!";
                btnAdd.Enabled          = true;
            }
        }
Esempio n. 20
0
        public SearchPoint HPScanAd(string url)
        {
            SearchPoint rec = new SearchPoint();

            rec.Id            = Guid.NewGuid();
            rec.WebSite       = 1;
            rec.CheckDate     = DateTime.Now;
            rec.UrlParameters = url.Trim();

            try
            {
                if (rec.UrlParameters.Substring(0, 1) != "/")
                {
                    rec.UrlParameters = "/" + rec.UrlParameters;
                }

                HtmlWeb web = new HtmlWeb();
                HtmlAgilityPack.HtmlDocument doc = web.Load(WebSiteContext.GetURL(rec.WebSite) + rec.UrlParameters);

                var price = doc.DocumentNode.Descendants("span").Where(d => d.Attributes.Count > 0 &&
                                                                       d.Attributes["id"] != null && d.Attributes["id"].Value.Contains("offering-price")).Select(a => a.Attributes["content"]).FirstOrDefault();

                if (price != null)
                {
                    rec.Price = Convert.ToDouble(price.Value);
                }

                string priceDiscounted = "";
                try
                {
                    priceDiscounted = doc.DocumentNode.Descendants("div").Where(d => d.Attributes.Count > 0 &&
                                                                                d.Attributes["class"] != null && d.Attributes["class"].Value.Contains("extra-discount-price")).Select(a => a.ChildNodes.Descendants("span").FirstOrDefault().InnerText).FirstOrDefault();

                    rec.Price = Convert.ToDouble(priceDiscounted);
                }
                catch (Exception)
                {
                    if (price == null)
                    {
                        return(null);
                    }
                }

                var name = doc.DocumentNode.Descendants("h1").Where(d => d.Attributes.Count > 0 &&
                                                                    d.Attributes["id"] != null && d.Attributes["id"].Value.Contains("product-name")).FirstOrDefault().InnerText;

                rec.Name = name.Trim().Replace("\r", "").Replace("\n", "");
            }
            catch (Exception e)
            {
                return(null);
            }

            return(rec);
        }
Esempio n. 21
0
        private void PerformLogin()
        {
            xmlMenuData =
                WebSiteContext.GetInstance().FacadeRepository.GetUserFacade().GetMenuItems(
                    Session[Constants.UserID].ToString());


            //Saving the bit of menu XML to session
            Session["MainMenu"] = xmlMenuData;
            Session["Login"]    = null;
        }
Esempio n. 22
0
        private void FillForm()
        {
            lblId.Text             = Rec.Id.ToString();
            txtName.Text           = Rec.Name;
            txtURL.Text            = Rec.UrlParameters;
            cbWebSite.SelectedItem = WebSiteContext.GetModel(Rec.WebSite);
            lblCheckDate.Text      = String.Format("{0:dd/MM/yyyy hh:mm:ss tt}", Rec.CheckDate);
            txtPrice.Text          = String.Format("{0:00}", Rec.Price);
            lblCurrency.Text       = WebSiteContext.GetCurrencyCode(Rec.WebSite);

            cbWebSite.Enabled = false;
        }
Esempio n. 23
0
 public WebDocument(
     BlogSetting blog,
     string id,
     string title,
     string content,
     IDocumentFactory documentFactory,
     IWebDocumentService webDocumentService,
     WebSiteContext siteContext) :
     base(title, content, blog.BlogName, documentFactory)
 {
     Id        = id;
     this.blog = blog;
     this.webDocumentService = webDocumentService;
     this.siteContext        = siteContext;
 }
Esempio n. 24
0
        public string Post(ArticleModel articleModel)
        {
            var success = "";

            try
            {
                Article newArticle = new Article();
                if (articleModel.Id == null)
                {
                    newArticle.Id = Guid.NewGuid().ToString();
                }
                else
                {
                    newArticle.Id = articleModel.Id;
                }
                newArticle.Title          = articleModel.Title;
                newArticle.CategoryRef    = articleModel.CategoryRef;
                newArticle.SubCategoryRef = articleModel.SubCategoryRef;
                newArticle.ImageName      = articleModel.ImageName;
                newArticle.Created        = DateTime.Now;
                newArticle.LastUpdated    = DateTime.Parse(articleModel.LastUpdated);
                newArticle.Content        = articleModel.Contents;
                newArticle.Summary        = articleModel.Summary;
                newArticle.ByLineRef      = articleModel.ByLineRef;

                foreach (DbArticleTagModel tag in articleModel.Tags)
                {
                    if (tag.TagName != null)
                    {
                        newArticle.ArticleTags.Add(new ArticleTag()
                        {
                            TagName = tag.TagName, TagCategoryRef = tag.TagCategoryRef
                        });
                    }
                }
                using (WebSiteContext db = new WebSiteContext())
                {
                    db.Articles.Add(newArticle);
                    db.SaveChanges();
                    success = newArticle.Id.ToString();
                }
            }
            catch (Exception ex)
            {
                success = Helpers.ErrorDetails(ex);
            }
            return(success);
        }
Esempio n. 25
0
        private void dgSearch_BindingContextChanged(object sender, EventArgs e)
        {
            if (dgSearch.Rows != null && dgSearch.Rows.Count > 0)
            {
                foreach (DataGridViewRow row in dgSearch.Rows)
                {
                    //Website
                    int websiteNum = (int)row.Cells["WebSite"].Value;
                    row.Cells["WebSiteStr"].Value = WebSiteContext.GetName(websiteNum);

                    //Price
                    double price = (double)row.Cells["Price"].Value;
                    row.Cells["PriceStr"].Value = String.Format("{0:00}", price) + " " + WebSiteContext.GetCurrencyCode(websiteNum);
                }
            }
        }
Esempio n. 26
0
 public WebDocument(
     BlogSetting blog,
     string id,
     string title,
     string content,
     IEnumerable <FileReference> associatedFiles,
     IDocumentFactory documentFactory,
     IWebDocumentService webDocumentService,
     WebSiteContext siteContext,
     IFileSystem fileSystem) :
     base(title, content, blog.BlogName, associatedFiles, documentFactory, siteContext, fileSystem)
 {
     Id        = id;
     this.blog = blog;
     this.webDocumentService = webDocumentService;
 }
Esempio n. 27
0
        public ArticleModel Get(string articleId)
        {
            var articleModel = new ArticleModel();

            try
            {
                using (WebSiteContext db = new WebSiteContext())
                {
                    Article dbArticle = db.Articles.Where(a => a.Id.ToString() == articleId).FirstOrDefault();
                    if (dbArticle != null)
                    {
                        articleModel.Title = dbArticle.Title;

                        try { articleModel.ByLineLabel = db.Refs.Where(r => r.RefCode == dbArticle.ByLineRef).FirstOrDefault().RefDescription; }
                        catch (Exception ex) { articleModel.ByLineLabel = Helpers.ErrorDetails(ex); }

                        try { articleModel.CategoryLabel = db.Refs.Where(r => r.RefCode == dbArticle.CategoryRef).FirstOrDefault().RefDescription; }
                        catch (Exception ex) { articleModel.CategoryLabel = Helpers.ErrorDetails(ex); }

                        //try { articleModel.SubCategoryLabel = db.Refs.Where(r => r.RefCode == dbArticle.SubCategoryRef).FirstOrDefault().RefDescription; }
                        //catch (Exception ex) { articleModel.SubCategoryLabel = Helpers.ErrorDetails(ex); }

                        articleModel.ByLineRef      = dbArticle.ByLineRef;
                        articleModel.CategoryRef    = dbArticle.CategoryRef;
                        articleModel.SubCategoryRef = dbArticle.SubCategoryRef;
                        articleModel.Contents       = dbArticle.Content;
                        articleModel.Summary        = dbArticle.Summary;
                        articleModel.Created        = dbArticle.Created;
                        articleModel.Updated        = dbArticle.LastUpdated;
                        articleModel.LastUpdated    = dbArticle.LastUpdated.ToShortDateString();
                        articleModel.ImageName      = dbArticle.ImageName;
                        //article.SortDate = dbArticle.LastUpdated.Value.ToString("yyyyMMdd");
                        foreach (ArticleTag tag in dbArticle.ArticleTags)
                        {
                            articleModel.Tags.Add(new DbArticleTagModel()
                            {
                                TagName = tag.TagName, Id = tag.Id, TagCategoryRef = tag.TagCategoryRef
                            });
                        }
                        articleModel.Success = "ok";
                    }
                }
            }
            catch (Exception ex) { articleModel.Success = Helpers.ErrorDetails(ex); }
            return(articleModel);
        }
Esempio n. 28
0
        // GET: api/Comments
        public IList <CommentsModel> Get(string articleId)
        {
            var results = new List <CommentsModel>();

            try
            {
                using (WebSiteContext db = new WebSiteContext())
                {
                    List <Comment> comments = db.Comments.Where(c => c.ArticleId == articleId).ToList();
                    foreach (Comment c in comments)
                    {
                        results.Add(new CommentsModel()
                        {
                            UserName     = c.UserName,
                            UserId       = c.UserId,
                            CommentId    = c.CommentId,
                            CommentTitle = c.CommentTitle,
                            CommentText  = c.CommentText,
                            CreateDate   = c.CreateDate.ToShortDateString()
                        });
                    }

                    //results = (from comments in db.Comments
                    //           join users in dbn.AspNetUsers on comments.UserId.ToString() equals users.Id
                    //           where comments.ArticleId.ToString() == articleId.ToString().ToUpper()
                    //           orderby comments.CreateDate ascending
                    //           select new CommentsModel
                    //           {
                    //               UserName = users.UserName,
                    //               UserId = users.Id,
                    //               CreateDate = comments.CreateDate,
                    //               CommentTitle = comments.CommentTitle,
                    //               CommentText = comments.CommentText
                    //           }).ToList().AsQueryable();
                }
            }
            catch (Exception ex)
            {
                results.Add(new CommentsModel()
                {
                    CommentText = Helpers.ErrorDetails(ex)
                });
                //results = results.Concat(new[] { new CommentsModel() { success = Helpers.ErrorDetails(ex) } });
            }
            return(results); //Json(results, JsonRequestBehavior.AllowGet);
        }
Esempio n. 29
0
        public string Post(DbArticleTagModel tag)
        {
            var success = "";

            try
            {
                var dbTag = new ArticleTag();
                dbTag.TagName   = tag.TagName;
                dbTag.articleId = tag.ArticleId;
                using (WebSiteContext db = new WebSiteContext())
                {
                    db.ArticleTags.Add(dbTag);
                    db.SaveChanges();
                    success = "ok";
                }
            }
            catch (Exception ex) { success = Helpers.ErrorDetails(ex); }
            return(success);
        }
Esempio n. 30
0
        public BlogModel GetOne(string blogId)
        {
            var blog = new BlogModel();

            try
            {
                using (WebSiteContext db = new WebSiteContext())
                {
                    var dbBlog = db.Blogs.Where(b => b.Id.ToString() == blogId).FirstOrDefault();
                    if (dbBlog != null)
                    {
                        blog.Id    = dbBlog.Id.ToString();
                        blog.Name  = dbBlog.BlogName;
                        blog.Color = dbBlog.Color;
                        blog.Owner = dbBlog.BlogOwner;
                    }
                }
            }
            catch (Exception ex) { blog.Name = Helpers.ErrorDetails(ex); }
            return(blog);
        }
Esempio n. 31
0
        public string Post(BlogModel newBlog)
        {
            var success = "";

            try
            {
                using (WebSiteContext db = new WebSiteContext())
                {
                    Blog blog = new Blog();
                    blog.Id        = Guid.NewGuid().ToString();
                    blog.BlogName  = newBlog.Name;
                    blog.Color     = newBlog.Color;
                    blog.BlogOwner = newBlog.Owner;

                    db.Blogs.Add(blog);
                    db.SaveChanges();
                    success = blog.Id.ToString();
                }
            }
            catch (Exception ex) { success = Helpers.ErrorDetails(ex); }
            return(success);
        }