Ejemplo n.º 1
0
        public bool UpdateMeetUp(Data.Model.MeetUp meetUp)
        {
            try
            {
                var oldMeetup = _meetUpContext.MeetUps
                                .Include(m => m.Address)
                                .Include(m => m.Lecture)
                                .Include(m => m.Visitors)
                                .FirstOrDefault(m => m.Id == meetUp.Id);

                oldMeetup.Lecture.Lecturer = meetUp.Lecture.Lecturer;
                oldMeetup.Lecture.Topic    = meetUp.Lecture.Topic;
                oldMeetup.From             = meetUp.From;
                oldMeetup.To             = meetUp.To;
                oldMeetup.Title          = meetUp.Title;
                oldMeetup.Address.Street = meetUp.Address.Street;
                oldMeetup.Address.Number = meetUp.Address.Number;
                oldMeetup.Date           = meetUp.Date;
                oldMeetup.MaxVisitors    = meetUp.MaxVisitors;

                _meetUpContext.SaveChanges();
            }
            catch (Exception e)
            {
                Trace.WriteLine("Exception: ", e.Message);

                return(false);
            }

            return(true);
        }
Ejemplo n.º 2
0
        public IActionResult GetMeetup(int id)
        {
            Data.Model.MeetUp meetUp = null;

            meetUp = _meetUpService.GetMeetUp(id);

            if (meetUp == null)
            {
                return(StatusCode(StatusCodes.Status404NotFound, "Meetup not found."));
            }

            return(Ok(meetUp));
        }
Ejemplo n.º 3
0
        public IActionResult UpdateMeetup(Data.Model.MeetUp model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(model));
            }

            if (!_meetUpService.UpdateMeetUp(model))
            {
                return(StatusCode(StatusCodes.Status400BadRequest, "Error while updating meetup"));
            }

            return(Ok());
        }
Ejemplo n.º 4
0
        public bool AddMeetUp(Data.Model.MeetUp meetUp)
        {
            try
            {
                _meetUpContext.MeetUps.Add(meetUp);
                _meetUpContext.Lectures.Add(meetUp.Lecture);
                _meetUpContext.Addresses.Add(meetUp.Address);
                _meetUpContext.SaveChanges();
            }
            catch (Exception e)
            {
                Trace.WriteLine("Exception:" + e.Message);

                return(false);
            }

            return(true);
        }
Ejemplo n.º 5
0
        public Data.Model.MeetUp GetMeetUp(int id)
        {
            Data.Model.MeetUp meetup = null;

            try
            {
                meetup = _meetUpContext.MeetUps
                         .Include(m => m.Address)
                         .Include(m => m.Lecture)
                         .Include(m => m.Visitors)
                         .FirstOrDefault(m => m.Id == id);
            }
            catch (Exception e)
            {
                Trace.WriteLine("Exception: " + e.Message);
            }

            return(meetup);
        }
Ejemplo n.º 6
0
        public bool CreateMeetUp(MeetupViewModel model)
        {
            Data.Model.MeetUp meetUp = new Data.Model.MeetUp
            {
                Address = new Address {
                    Number = model.HouseNmb, Street = model.Street
                },
                CurrentVisitorsCount = 0,
                Date    = model.Date,
                From    = model.From,
                To      = model.To,
                Lecture = new Lecture {
                    Lecturer = model.Lecturer, Topic = model.Topic
                },
                MaxVisitors = model.MaxVisitors,
                Title       = model.Title,
                CreatedById = model.CreatorId
            };

            return(_meetUpRepository.AddMeetUp(meetUp));
        }
Ejemplo n.º 7
0
 public bool UpdateMeetUp(Data.Model.MeetUp meetUp)
 {
     return(_meetUpRepository.UpdateMeetUp(meetUp));
 }