示例#1
0
        public async Task <IActionResult> UpdateEvent(Guid eventId, [FromBody] DTOs.Event eventForUpdate, int DocCnt)
        {
            var eventFromRepo = await _armsEventRepository.GetArmsEventIdAsync(eventId);

            if (eventFromRepo == null)
            {
                return(BadRequest());
            }

            eventForUpdate.UserId = "preicher";
            _armsEventRepository.UpdateArmsEventType(_mapper.Map(eventForUpdate, eventFromRepo));
            var EvtCopy = _mapper.Map <DTOs.Event>(eventFromRepo);

            EvtCopy.DocCnt = await _fileUploads.GetUploadCountBySrcIdAsync(eventForUpdate.EventId ?? Guid.Empty);

            return(Ok(EvtCopy));
        }
示例#2
0
        public async Task <IActionResult> AddEvent([FromBody] DTOs.Event eventForCreate)
        {
            Entities.Event evnt;
            try
            {
                eventForCreate.UserId = "preicher";
                evnt = _mapper.Map <Entities.Event>(eventForCreate);
                await _armsEventRepository.AddArmsEventAsync(evnt);
            }
            catch (Exception ex)
            {
                Log.Error(ex.Message);
                return(StatusCode(500));
            }
            var EvtCopy = _mapper.Map <DTOs.Event>(evnt);

            EvtCopy.DocCnt = 0;
            return(Ok(EvtCopy));
        }