Ejemplo n.º 1
0
        public string AddEvent(EventViewModel evm)
        {
            var user = _manager.FindById(CurrentUser.UserId);

            var newEvent = new Event
            {
                User = user,
                Title = evm.Title,
                Description = evm.Description,
                Date = evm.Date,
                Start = evm.Start,
                End = evm.End
            };

            _eventsService.Add(newEvent);

            var evnt = new CalendarEvent
            {
                title = newEvent.Title,
                description = newEvent.Description,
                start = Helpers.CombineDateWithTime(newEvent.Start, newEvent.Date),
                end = Helpers.CombineDateWithTime(newEvent.End, newEvent.Date),
                id = newEvent.EventId
            };

            var json = JsonConvert.SerializeObject(evnt, Formatting.None,
                        new JsonSerializerSettings
                        {
                            ReferenceLoopHandling = ReferenceLoopHandling.Ignore
                        });

            return json;
        }
Ejemplo n.º 2
0
 public void Update(Event evt)
 {
     _context.Set<Event>().AddOrUpdate(evt);
     _context.SaveChanges();
 }
Ejemplo n.º 3
0
 public void Add(Event evt)
 {
     _context.Events.Add(evt);
     _context.SaveChanges();
 }
Ejemplo n.º 4
0
        public string UpdateEvent(EventViewModel evm)
        {
            var user = _manager.FindById(CurrentUser.UserId);
            var evId = evm.Id;

            var evt = new Event
            {
                EventId = evm.Id,
                User = user,
                Title = evm.Title,
                Description = evm.Description,
                Date = evm.Date,
                Start = evm.Start,
                End = evm.End
            };
            _eventsService.Update(evt);

            var json = JsonConvert.SerializeObject(evId);

            return json;
        }