public bool UpdateEvent(EventBlockEdit model) { using (var ctx = new StudyTimeHelperEntities()) { var entity = ctx .Event .Single(e => e.EventId == model.EventId); entity.Title = model.Title; entity.IsAllDay = model.IsAllDay; entity.Start = model.Start; entity.End = model.End; entity.Description = model.Description; entity.ThemeColor = model.ThemeColor; return(ctx.SaveChanges() == 1); } }
public bool CreateEvent(EventBlockCreate model) { var entity = new Data.Event() { Title = model.Title, IsAllDay = model.IsAllDay, Start = model.Start, End = model.End, Description = model.Description, ThemeColor = model.ThemeColor, }; using (var ctx = new StudyTimeHelperEntities()) { ctx.Event.Add(entity); return(ctx.SaveChanges() == 1); } }
public EventBlockDetail GetEventBlockById(int id) { using (var ctx = new StudyTimeHelperEntities()) { var entity = ctx .Event .Single(e => e.EventId == id && e.StudentId == _studentId); return (new EventBlockDetail { EventId = entity.EventId, Title = entity.Title, IsAllDay = entity.IsAllDay, Start = entity.Start, End = entity.End, Description = entity.Description, ThemeColor = entity.ThemeColor, }); } }
public IEnumerable <EventBlockListItem> GetEvent() { using (var ctx = new StudyTimeHelperEntities()) { var query = ctx .Event .Select( e => new EventBlockListItem { EventId = e.EventId, Title = e.Title, IsAllDay = e.IsAllDay, Start = e.Start, End = e.End, Description = e.Description, ThemeColor = e.ThemeColor, }); return(query.ToArray()); } }