protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                int itemId = Convert.ToInt32(Request.Params["id"]);

                if (itemId != 0)
                {
                    Model.Articles item = DataHelper.GetOneArticle(itemId);

                    TextBoxDate.Text = item.WhenDate.ToString("dd.MM.yyyy");

                    TextBoxHead.Text = item.Head;

                    NewsText.Text = item.Text;

                    LabelAuthor.Text = DataHelper.GetUser(item.UserId).UserName;
                }
                else
                {
                    LabelAuthor.Text = User.UserName;

                    TextBoxDate.Text = DateTime.Now.ToString("dd.MM.yyyy");
                }
            }
        }
Beispiel #2
0
 public async Task UpdateArticle(Model.Articles model)
 {
     try
     {
         await db.UpdateAsync(model);
     }
     catch (Exception ex)
     {
         Log.SaveLog("UpdateArticle", ex);
     }
 }
Beispiel #3
0
 public async Task UpdateArticle(Model.Articles model)
 {
     try
     {
         await db.UpdateAsync(model);
     }
     catch (Exception ex)
     {
         Crashes.TrackError(ex);
     }
 }
        public bool UpdateArticle(Model.Articles updArticle)
        {
            using (var _client = new HttpClient())
            {
                _client.BaseAddress = new Uri(BASE_URL);
                _client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

                var byteArray = Encoding.ASCII.GetBytes("my_user:my_password");
                _client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", Convert.ToBase64String(byteArray));

                var response = _client.PutAsJsonAsync($"services/Articles/{updArticle.Id}", updArticle).Result;

                return(true);
            }
        }
        public Fangor.Model.Articles GetModel(SqlDataReader Reader)
        {
            Fangor.Model.Articles result = new Model.Articles();

            result.Article_Id1 = Convert.ToInt32(Reader["Article_Id"].ToString());

            result.Article_Title1 = Reader["Article_Title"].ToString();

            Fangor.Model.UserInfo users = new Fangor.Model.UserInfo();

            users.User_Name1 = GetUserNameById(Convert.ToInt32(Reader["Article_Writer"]));

            result.Article_Writer1 = users;

            //result.Article_Writer1.User_Id1 = Convert.ToInt32(Reader["Article_Writer"]);

            result.Article_Content1 = Reader["Article_Content"].ToString();

            result.Article_Time1 = Convert.ToDateTime(Reader["Article_Time"]);

            result.Article_Top1 = Convert.ToInt32(Reader["Article_Top"]);

            result.Article_Type1 = Convert.ToInt32(Reader["Article_Type"]);

            result.Article_Click1 = Convert.ToInt32(Reader["Article_Click"]);

            result.Article_Type1 = Convert.ToInt32(Reader["Article_Type"]);

            result.Article_Time1 = Convert.ToDateTime(Reader["Article_Time"]);

            result.Article_Reply1 = Convert.ToInt32(Reader["Article_Reply"]);

            result.Article_Red1 = Convert.ToInt32(Reader["Article_Red"]);

            if (result.Article_Type1 == 1)
            {
                Fangor.Model.Images Images = new Fangor.Model.Images();

                Images.Image_Url1 = GetImagePathById(Convert.ToInt32(Reader["Article_Picture"]));

                result.Article_Picture1 = Images;
            }

            return result;
        }
Beispiel #6
0
        public Boolean UpdateArticle(Model.Articles updArticle)
        {
            using (UnitOfWork _unitOfWork = new UnitOfWork())
            {
                Article _article = _unitOfWork.ArticlesRepository.GetById(updArticle.Id);

                _article.Description  = updArticle.Description;
                _article.Name         = updArticle.Name;
                _article.Price        = updArticle.Price;
                _article.Store_Id     = updArticle.Store_Id;
                _article.TotalInShelf = updArticle.TotalInShelf;
                _article.TotalInVault = updArticle.TotalInVault;

                _unitOfWork.Save();

                return(true);
            }
        }
Beispiel #7
0
        public Boolean CreateArticle(Model.Articles newArticle)
        {
            using (UnitOfWork _unitOfWork = new UnitOfWork())
            {
                Article _article = new Article();

                _article.Description  = newArticle.Description;
                _article.Name         = newArticle.Name;
                _article.Price        = newArticle.Price;
                _article.Store_Id     = newArticle.Store_Id;
                _article.TotalInShelf = newArticle.TotalInShelf;
                _article.TotalInVault = newArticle.TotalInVault;

                _unitOfWork.ArticlesRepository.Insert(_article);
                _unitOfWork.Save();

                return(true);
            }
        }
        protected void ButtonSave_Click(object sender, EventArgs e)
        {
            Model.Articles item = new Model.Articles();

            int itemId = 0;

            try
            {
                itemId = Convert.ToInt32(Request.Params["id"]);
            }
            catch (System.Exception ex)
            {
                DataHelper.AddException(ex);
            }

            if (itemId != 0)
            {
                item.Id = itemId;
            }

            try
            {
                var myDate = DateTime.ParseExact(TextBoxDate.Text, "dd.MM.yyyy", System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.None);

                item.WhenDate = myDate;
                item.Head     = TextBoxHead.Text;
                item.Text     = NewsText.Text;
                item.UserId   = User.UserId;

                DataHelper.SubmitArticle(item);
            }
            catch (System.Exception ex)
            {
                DataHelper.AddException(ex);
            }

            Response.Redirect("Articles.aspx");
        }
 public void Put(int id, [FromBody] Model.Articles article)
 {
     _articlesApp.UpdateArticle(article);
 }
 public void Post([FromBody] Model.Articles article)
 {
     _articlesApp.CreateArticle(article);
 }