public ActionResult New(EventInfo post) { post.CreatedByUserId = Guid.Parse(User.Identity.GetUserId()); int newEventId = _pm.CreateEvent(post); return RedirectToAction("Details", "Event", new { id = newEventId }); }
public ActionResult Details(EventInfo post) { _pm.UpdateEvent(post); return RedirectToAction("Details", "Event", new { id = post.Id }); }
public ActionResult New() { var emptyEvent = new EventInfo(); emptyEvent.AvailableGroups = _pm.GetAvailableGroups(); return View("Details", emptyEvent); }
public EventInfo GetEvent(int postId) { var post = _context.Events .Include(g => g.Groups) .Include(u => u.CreatedByUser) .FirstOrDefault(w => w.Id == postId); var md = new MarkdownDeep.Markdown(); md.ExtraMode = true; md.SafeMode = false; EventInfo mappedPost; mappedPost = new EventInfo() { PublishStartTime = post.PublishStartTime, PublishEndTime = post.PublishEndTime, IsDeleted = post.IsDeleted, Body = post.Body, HtmlBody = md.Transform(post.Body), HtmlBodySummary = md.Transform(post.Body.Length <= 500 ? post.Body : post.Body.Substring(0, 500)), CreatedByUserId = post.CreatedByUserId, EventEndTime = (post as Event).EventEndTime, EventStartTime = (post as Event).EventStartTime, Id = post.Id, Title = post.Title, AvailableGroups = AvailableGroups, GroupTags = post.Groups.Select(g => g.Id), CreatedByUserName = GetUserName(post.CreatedByUser), VimeoId = (post as Event).VimeoId }; return mappedPost; }
public int CreateEvent(EventInfo newEvent) { var newDbEvent = new Event(); newDbEvent.Groups = _context.Groups.Where(g => newEvent.GroupTags.Contains(g.Id)).ToList(); newDbEvent.IsDeleted = newEvent.IsDeleted; newDbEvent.EventEndTime = newEvent.EventEndTime; newDbEvent.EventStartTime = newEvent.EventStartTime; newDbEvent.PublishEndTime = newEvent.PublishEndTime; newDbEvent.PublishStartTime = newEvent.PublishStartTime; newDbEvent.Title = newEvent.Title; newDbEvent.Body = newEvent.Body; newDbEvent.CreatedByUserId = newEvent.CreatedByUserId; newDbEvent.VimeoId = newEvent.VimeoId; _context.Events.Add(newDbEvent); _context.SaveChanges(); return newDbEvent.Id; }
public void UpdateEvent(EventInfo updateEvent) { var eventToUpdate = _context.Events .Include(cbu => cbu.CreatedByUser) .Include(g => g.Groups) .FirstOrDefault(w => w.Id == updateEvent.Id); eventToUpdate.Groups = _context.Groups.Where(g => updateEvent.GroupTags.Contains(g.Id)).ToList(); eventToUpdate.IsDeleted = updateEvent.IsDeleted; eventToUpdate.EventEndTime = updateEvent.EventEndTime; eventToUpdate.EventStartTime = updateEvent.EventStartTime; eventToUpdate.PublishEndTime = updateEvent.PublishEndTime; eventToUpdate.PublishStartTime = updateEvent.PublishStartTime; eventToUpdate.Title = updateEvent.Title; eventToUpdate.Body = updateEvent.Body; eventToUpdate.VimeoId = updateEvent.VimeoId; _context.SaveChanges(); }