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>()); }
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)); }
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)); }
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)); } }
public IActionResult Create(EventViewModel model) { eventsRepo.Add(model.Listing); return(RedirectToAction("CreateLocation", new { id = model.Listing.Id.ToString() })); }