public IActionResult Create([FromBody] EventStatusViewModel eventStatusvm)
        {
            if (!ModelState.IsValid || eventStatusvm == null)
            {
                return(BadRequest(ModelState));
            }

            EventDetailStatus _eventStatus = _mapper.Map <EventStatusViewModel, EventDetailStatus>(eventStatusvm);

            EventDetailStatus _newCreatedEventStatus = _eventStatusRepository.CreateEventStatusDetail(_eventStatus);

            if (_newCreatedEventStatus == null)
            {
                Log.Information("Error Inserting Event Status {@eventStatusvm} Into database", eventStatusvm);
                return(NotFound(new ResultVM()
                {
                    Status = Status.Error, Message = "An Error Occuered Could not create Event Status" + eventStatusvm.event_detail_status_name, Data = eventStatusvm
                }));
            }

            eventStatusvm = _mapper.Map <EventDetailStatus, EventStatusViewModel>(_newCreatedEventStatus);
            Log.Information("Event Status {@eventStatusvm} Inserted to database", eventStatusvm);
            return(new OkObjectResult(new ResultVM()
            {
                Status = Status.Success, Message = "Succesfully Created Event Status: " + eventStatusvm.event_detail_status_name, Data = eventStatusvm
            }));
        }
        public IActionResult Get(long id)
        {
            EventDetailStatus _eventStatus = _eventStatusRepository.GetSingle(u => u.Id == id);

            if (_eventStatus != null)
            {
                EventStatusViewModel _eventStatusVM = _mapper.Map <EventDetailStatus, EventStatusViewModel>(_eventStatus);
                Log.Information("Event Status {@_eventStatusVM} retrieved from database", _eventStatusVM);
                return(new OkObjectResult(new ResultVM()
                {
                    Status = Status.Success, Data = _eventStatusVM
                }));
            }
            else
            {
                Log.Information("Could not find Event Status wit Id  {@id}", id);
                return(NotFound());
            }
        }
 public IActionResult Update([FromBody] EventStatusViewModel eventstatusvm)
 {
     if (eventstatusvm != null)
     {
         EventDetailStatus _eventStatus = _mapper.Map <EventStatusViewModel, EventDetailStatus>(eventstatusvm);
         _eventStatusRepository.Update(_eventStatus);
         _eventStatusRepository.Commit();
         EventStatusViewModel _eventStatusVM = _mapper.Map <EventDetailStatus, EventStatusViewModel>(_eventStatus);
         return(new OkObjectResult(new ResultVM()
         {
             Data = _eventStatusVM, Status = Status.Success
         }));
     }
     else
     {
         Log.Information("Error Occured Updating Event Status {@eventstatusvm}", eventstatusvm);
         return(NotFound(new ResultVM()
         {
             Status = Status.Error, Message = "An Error Occured: ", Data = null
         }));
     }
 }
        public IActionResult Delete(long id)
        {
            EventDetailStatus _eventStatus = _eventStatusRepository.GetSingle(u => u.Id == id);

            if (_eventStatus != null)
            {
                _eventStatusRepository.Delete(_eventStatus);
                _eventStatusRepository.Commit();
                EventStatusViewModel _eventStatusVM = _mapper.Map <EventDetailStatus, EventStatusViewModel>(_eventStatus);
                Log.Information("Event Status {@_eventStatusVM} Deleted from database", _eventStatusVM);
                return(new OkObjectResult(new ResultVM()
                {
                    Status = Status.Success, Message = "Succesfully Deleted Event Status: " + _eventStatusVM.event_detail_status_name, Data = _eventStatusVM
                }));
            }
            else
            {
                Log.Information("Error Occured Deleting Event Status from database");
                return(NotFound(new ResultVM()
                {
                    Status = Status.Error, Message = "An Error Occured: ", Data = null
                }));
            }
        }