示例#1
0
        public ActionResult Create(EventInputModel model)
        {
            if (model != null && this.ModelState.IsValid)
                {
                    var e = new Event()
                    {
                        AuthorId = this.User.Identity.GetUserId(),
                        Title = model.Title,
                        StartDateTime = model.StartDateTime,
                        Description = model.Description,
                        Location = model.Location,
                        IsPublic = model.IsPublic
                    };
                    string role = roleCheck();
                    ViewBag.userRole = role;
                    this.db.Events.Add(e);
                    this.db.SaveChanges();
                    this.AddNotification("Event created", NotificationType.INFO);
                    // Display success notification
                    return this.RedirectToAction("My");

                }

                return this.View(model);
        }
 public static EventInputModel CreateFromEvent(Event e)
 {
     return new EventInputModel()
     {
         Title = e.Title,
         StartDateTime = e.StartDateTime,
         Duration = e.Duration,
         Location = e.Location,
         Description = e.Description,
         IsPublic = e.IsPublic
     };
 }
示例#3
0
 public static EventInputModel CreateFromEvent(Event eventToEdit)
 {
     return new EventInputModel()
     {
         Title = eventToEdit.Title,
         ImageUrl=eventToEdit.ImageUrl,
         StartDateTime = eventToEdit.StartDateTime,
         Duration = eventToEdit.Duration,
         Location = eventToEdit.Location,
         Description = eventToEdit.Description,
         IsPublic = eventToEdit.IsPublic
     };
 }
示例#4
0
 public static EventInputModel CreateFromEvent(Event e)
 {
     return new EventInputModel()
     {
         Title = e.Title,
         StartDateTime = e.StartDateTime,
         Duration = e.Duration,
         Address = e.Address,
         City = e.City,
         State = e.State,
         Zip = e.Zip.GetValueOrDefault() > 9999 ? e.Zip.GetValueOrDefault().ToString() : string.Empty,
         Description = e.Description,
         IsPublic = e.IsPublic
     };
 }
示例#5
0
        public ActionResult Create(Event eventModel)
        {
            var errors = ModelState.Select(m => m.Value.Errors);
            if (!ModelState.IsValid)
            {
                return View(eventModel);
            }
            var player = CurrentPlayer();

            eventModel.HostId = player.PlayerId;
            eventModel.CreatedOn = DateTime.Now;
            //eventModel.StartTime = DateTime.Now;

            context.Events.Add(eventModel);
            context.SaveChanges();
            return RedirectToAction("Index");
        }
        public ActionResult Create(EventInputModel model)
        {
            if (model != null && this.ModelState.IsValid)
            {
                var e = new Event()
                {
                    AuthorId = this.User.Identity.GetUserId(),
                    Title = model.Title,
                    StartDateTime = model.StartDateTime,
                    Duration = model.Duration,
                    Description = model.Description,
                    Location = model.Location,
                    IsPublic = model.IsPublic
                };
                this.eventsdb.Events.Add(e);
                this.eventsdb.SaveChanges();
                this.AddNotification("Event created.", NotificationType.INFO);
                return this.RedirectToAction("My");
            }

            return this.View(model);
        }
示例#7
0
        public ActionResult Edit(Event eventModel)
        {
            if (!ModelState.IsValid)
            {
                return View(eventModel);
            }

            context.Entry(eventModel).State = EntityState.Modified;
            context.SaveChanges();
            return RedirectToAction("Index");
        }
示例#8
0
        public ActionResult Create(EventInputModel model)
        {
            string lat = string.Empty;
            string lon = string.Empty;
            EventfulSearch coorResolver = new EventfulSearch();
            string[] coord = resolveCoordinates(model.Address, model.City, model.State, model.Zip);

            int zip = 0;
            int.TryParse(model.Zip, out zip);

            if (coord != null && coord.Length == 2)
            {
                lat = coord[0];
                lon = coord[1];
            }

            if (model != null && this.ModelState.IsValid)
            {
                var e = new Event()
                {
                    AuthorId = this.User.Identity.GetUserId(),
                    Title = model.Title,
                    StartDateTime = model.StartDateTime,
                    Duration = model.Duration,
                    Description = model.Description,
                    Address = model.Address,
                    City = model.City,
                    Lat = lat,
                    Lon = lon,
                    State = model.State,
                    Zip = zip > 9999 ? new Nullable<int>(zip) : null,
                    IsPublic = model.IsPublic
                };

                this.eventsdb.Events.Add(e);
                this.eventsdb.SaveChanges();

                List<string> invitedUsers = new List<string>();
                if(Request["Friends"]!= null)
                {
                    invitedUsers = Request["Friends"].Split(',').ToList();
                }

                foreach(string invitedUser in invitedUsers)
                {
                    var invite = new EventInvite();
                    invite.FromUser = this.User.Identity.GetUserId();
                    invite.ToUser = invitedUser;
                    invite.EventId = e.Id;

                    eventsdb.EventInvites.Add(invite);
                }
                eventsdb.SaveChanges();

                if (Request.Files != null && Request.Files.Count > 0)
                {
                    SaveImages(e.Id);
                }

                this.AddNotification("Event created.", NotificationType.INFO);
                return this.RedirectToAction("My");
            }

            return this.View(model);
        }