예제 #1
0
        public ActionResult AddBanner(BannerViewModel viewModel)
        {
            if(ModelState.IsValid)
            {
                var banner = new HeaderElement()
                    {
                        Title = viewModel.Title,
                        Text = viewModel.Text,
                        PostedAt = DateTime.Now,
                        Account = accountRepository.GetByUsername(CurrentUserName)
                    };

                bannersRepository.Add(banner);

                TempData[Const.ActionResultInfo] = "Баннер успешно добавлен";
                return RedirectToAction("Banners");
            }

            TempData[Const.ActionErrorInfo] = "Ошибка добавления баннера. Проверьте правильность введенных данных.";
            return View(viewModel);
        }
예제 #2
0
 /// <summary>
 /// Create a new HeaderElement object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="title">Initial value of the Title property.</param>
 /// <param name="text">Initial value of the Text property.</param>
 /// <param name="postedAt">Initial value of the PostedAt property.</param>
 /// <param name="accountId">Initial value of the AccountId property.</param>
 public static HeaderElement CreateHeaderElement(global::System.Int32 id, global::System.String title, global::System.String text, global::System.DateTime postedAt, global::System.Int32 accountId)
 {
     HeaderElement headerElement = new HeaderElement();
     headerElement.Id = id;
     headerElement.Title = title;
     headerElement.Text = text;
     headerElement.PostedAt = postedAt;
     headerElement.AccountId = accountId;
     return headerElement;
 }
예제 #3
0
 /// <summary>
 /// Deprecated Method for adding a new object to the HeaderElementSet EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToHeaderElementSet(HeaderElement headerElement)
 {
     base.AddObject("HeaderElementSet", headerElement);
 }