示例#1
0
        public async Task <MeetingEntity> CreateMeetingAsync(CreateMeetingEntity createMeetingEntity)
        {
            var meetingType   = _meetingTypeRepository.Where(mt => mt.Id == createMeetingEntity.MeetingTypeId).FirstOrDefault().Name;
            var numOfMeetings = _meetingRepository.Where(m => m.MeetingTypeId == createMeetingEntity.MeetingTypeId).Count();

            var meeting = new Meeting
            {
                MeetingTypeId = createMeetingEntity.MeetingTypeId,
                DateTime      = createMeetingEntity.DateTime,
                Number        = $"{meetingType.Substring(0,1)}{numOfMeetings + 1}",
                CreatedAt     = DateTimeOffset.Now,
                UpdatedAt     = DateTimeOffset.Now
            };

            _meetingRepository.Add(meeting);
            await _meetingRepository.SaveAsync();

            await AddCarriedOverItems(meeting, createMeetingEntity);

            return(new MeetingEntity
            {
                Id = meeting.Id,
                DateTime = meeting.DateTime,
                CreatedAt = meeting.CreatedAt,
                UpdatedAt = meeting.UpdatedAt
            });
        }
示例#2
0
        private async Task AddCarriedOverItems(Meeting meeting, CreateMeetingEntity createMeetingEntity)
        {
            if (createMeetingEntity.CarriedOverItemIds != null)
            {
                foreach (var id in createMeetingEntity.CarriedOverItemIds)
                {
                    var currentStatus = _itemRepository.Where(i => i.Id == id).FirstOrDefault().ItemStatusId;

                    var meetingItem = new MeetingItem
                    {
                        MeetingId = meeting.Id,
                        ItemId    = id,
                    };

                    _meetingItemRepository.Add(meetingItem);
                    await _meetingItemRepository.SaveAsync();
                }
                ;
            }
        }