示例#1
0
 /// <summary>
 /// Create a new Event object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="title">Initial value of the Title property.</param>
 /// <param name="date">Initial value of the Date property.</param>
 /// <param name="text">Initial value of the Text property.</param>
 /// <param name="location">Initial value of the Location property.</param>
 /// <param name="accountId">Initial value of the AccountId property.</param>
 public static Event CreateEvent(global::System.Int32 id, global::System.String title, global::System.DateTime date, global::System.String text, global::System.String location, global::System.Int32 accountId)
 {
     Event @event = new Event();
     @event.Id = id;
     @event.Title = title;
     @event.Date = date;
     @event.Text = text;
     @event.Location = location;
     @event.AccountId = accountId;
     return @event;
 }
示例#2
0
        public ActionResult AddEvent(EventViewModel ev)
        {
            if (ModelState.IsValid)
            {
                var date = DateTime.ParseExact(ev.Date, "dd.MM.yyyy HH:mm", CultureInfo.InvariantCulture);

                using (new UnitOfWork(_currentContext))
                {
                    var newEvent = new Event
                                       {
                                           Account = accountRepository.GetByUsername(CurrentUserName),
                                           Title = ev.Title,
                                           Text = ev.Text,
                                           Date = date,
                                           Location = ev.Location
                                       };
                    eventsRepository.Add(newEvent);
                }
                TempData[Const.ActionResultInfo] = "Мероприятие успешно добавлено";
                return RedirectToAction("Events");
            }

            TempData[Const.ActionErrorInfo] = "Невозможно добавить мероприятие. Проверьте правильность введенных данных";
            return View();
        }
示例#3
0
 /// <summary>
 /// Deprecated Method for adding a new object to the EventSet EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToEventSet(Event @event)
 {
     base.AddObject("EventSet", @event);
 }