Пример #1
0
 /// <summary>
 /// Конструктор по умолчанию
 /// </summary>
 /// <param name="event"></param>
 public EventDetailsModel(Event @event)
     : base(@event)
 {
     description = @event.Description;
     event_end = @event.EndDateTime.FormatDateTime();
     placeName = @event.Place.Title;
     placeId = @event.PlaceId;
 }
Пример #2
0
 /// <summary>
 /// Конструктор по умолчанию
 /// </summary>
 /// <param name="event"></param>
 public EventModel(Event @event)
 {
     id = @event.Id;
     title = @event.Title;
     img = @event.Image;
     event_start = @event.StartDateTime.FormatDateTime();
     objType = "event";
 }
Пример #3
0
        public ActionResult SaveEvent(Event model,string startTime, string endTime)
        {
            var file = Request.Files["Image"];
            string imageUrl = null;
            if (file != null && file.ContentLength > 0 && file.ContentType.ToLower().Contains("image"))
            {
                var fileName = Path.ChangeExtension(Path.GetRandomFileName(), ".jpg");
                var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Files", "Events");
                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }
                var fullPath = Path.Combine(path, fileName);
                ImageHelper.SaveAs(file, fullPath);
                imageUrl = "/Files/Events/" + fileName;
            }

            // Устанавливаем время событий
            //DateUtils.SetTime(model.StartDateTime, startTime);
            //DateUtils.SetTime(model.EndDateTime, endTime);

            if (model.Id <= 0)
            {
                model.DateCreated = DateTime.Now;
                model.Image = imageUrl;
                EventsRepository.Add(model);
                EventsRepository.SubmitChanges();
                ShowSuccess("Событие успешно добавлено");
            }
            else
            {
                // Ищем
                var @event = EventsRepository.Load(model.Id);
                if (@event == null)
                {
                    ShowError("Такое заведение не найдено");
                    return RedirectToAction("Index");
                }

                // Пытаемся обновить
                var oldImage = @event.Image;
                TryUpdateModel(@event);
                @event.StartDateTime = model.StartDateTime;
                @event.EndDateTime = model.EndDateTime;
                @event.DateModified = DateTime.Now;
                @event.Image = imageUrl ?? oldImage;
                Repository.SubmitChanges();

                ShowSuccess("Событие успешно отредактировано");
            }

            return RedirectToAction("Events",new {id = model.PlaceId});
        }
Пример #4
0
		private void detach_Events(Event entity)
		{
			this.SendPropertyChanging();
			entity.Place = null;
		}
Пример #5
0
		private void attach_Events(Event entity)
		{
			this.SendPropertyChanging();
			entity.Place = this;
		}