示例#1
0
        public OperationResult <int> AddEvent(Event eventEntity)
        {
            var result = new OperationResult <int>();

            try
            {
                _eventRepo.Add(eventEntity);
                var saveResult = _context.SaveChanges();
                if (saveResult > 0)
                {
                    result.Data   = eventEntity.EventId;
                    result.Status = eOperationStatus.Success;
                }
                else
                {
                    result.Data   = 0;
                    result.Status = eOperationStatus.GeneralError;
                }
            }
            catch (Exception ex)
            {
                result.Status           = eOperationStatus.GeneralError;
                result.ExceptionMessage = ex.Message;
                result.Data             = 0;
            }

            return(result);
        }
        public EventResource Add(Event input)
        {
            var entity = _repository.Add(input);

            SaveChanges();
            return(entity.Adapt <EventResource>());
        }
示例#3
0
文件: Seed.cs 项目: jbyall/looking2
        public static void SeedEvents(IEventsRepository _eventRepo)
        {
            var events = GetSeedEventListings();

            foreach (var e in events)
            {
                _eventRepo.Add(e);
            }
        }
        public IActionResult Add([FromBody] Event newEvent)
        {
            if (newEvent.Id < 1)
            {
                return(BadRequest("Invalid id"));
            }

            repository.Add(newEvent);
            return(CreatedAtAction(nameof(GetById), new { id = newEvent.Id }, newEvent));
        }
示例#5
0
        public EventDetailDto Post([FromBody] CreateEventDto eventDto)
        {
            var newEvent = _mapper.Map <ScheduledEvent>(eventDto);

            Request.Headers.TryGetValue("User-Id", out var userId);
            newEvent.CreatedByUserId = Guid.Parse(userId);

            var result = _eventsRepo.Add(newEvent);

            return(_mapper.Map <EventDetailDto>(result));
        }
示例#6
0
 public ActionResult Post([FromBody] CreateEventModel model)
 {
     try
     {
         var eventEntity = new Event(model.ApplicationId, model.ItemId, model.TriggeredBy, model.Type);
         _eventsRepository.Add(eventEntity);
         return(Ok());
     } catch (Exception ex)
     {
         return(StatusCode(StatusCodes.Status500InternalServerError));
     }
 }
示例#7
0
 public IActionResult Create(EventViewModel model)
 {
     eventsRepo.Add(model.Listing);
     return(RedirectToAction("CreateLocation", new { id = model.Listing.Id.ToString() }));
 }