コード例 #1
0
        public void RemoveScheduleItem(int id)
        {
            var scheduleItem = Entity.ScheduleItems.SingleOrDefault(i => i.ScheduleItemID == id);

            if (scheduleItem != null)
            {
                Entity.ScheduleItems.Remove(scheduleItem);
                scheduleItemRepository.Delete(scheduleItem);
                scheduleRepository.Save();
            }
        }
コード例 #2
0
        public bool Delete(int id)
        {
            try
            {
                var scheduleItemDto = GetById(id);
                if (scheduleItemDto == null)
                {
                    _logger.LogError($"ScheduleItem with id: {id}, hasn't been found in db.");
                    return(false);
                }

                ScheduleItem scheduleItem = _mapper.Map <ScheduleItem>(scheduleItemDto);

                _repository.Delete(scheduleItem);
                _repository.Save();

                return(true);
            }
            catch (Exception ex)
            {
                _logger.LogError($"Something went wrong inside DeleteScheduleItem action: {ex.Message}");
                throw new Exception();
            }
        }