Ejemplo n.º 1
0
        public bool AddEvent(AddEventDto dto)
        {
            string imageFileName;

            if (ImageFileHelper.SaveFile(dto.Image, out imageFileName))
            {
                Domain.Entity.Event eventToAdd = _mapper.Map <Domain.Entity.Event>(dto);
                eventToAdd.ImageFilename = imageFileName;
                _context.Events.Add(eventToAdd);
                return(_context.SaveChanges() > 0);
            }
            return(false);
        }
Ejemplo n.º 2
0
        public EditEventDto EditEvent(EditEventDto dto)
        {
            var eventToEdit = _context.Events.SingleOrDefault(e => e.EventId == dto.EventId);

            eventToEdit.Name        = dto.Name;
            eventToEdit.Street      = dto.Description;
            eventToEdit.Date        = dto.Date;
            eventToEdit.Description = dto.Description;
            eventToEdit.AudienceKey = dto.AudienceKey;
            eventToEdit.City        = dto.City;

            if (dto.Image != null)
            {
                ImageFileHelper.SaveFile(dto.Image, out var imageFileName);
                eventToEdit.ImageFilename = imageFileName;
            }

            _context.SaveChanges();

            return(_mapper.Map <Domain.Entity.Event, EditEventDto>(eventToEdit));
        }