예제 #1
0
        public async Task AddModuleAsync(ModuleDto moduleDto)
        {
            if (moduleDto == null)
            {
                throw new ArgumentNullException(nameof(moduleDto));
            }

            context.Modules.Add(moduleDto.ToModule());

            await context.SaveChangesAsync();
        }
예제 #2
0
        public async Task <int> AddModuleAsync(ModuleDto moduleDto)
        {
            if (moduleDto == null)
            {
                throw new ArgumentNullException($"Argument {nameof(moduleDto)} can't be null!");
            }

            context.Set <Module>().Add(moduleDto.ToModule());

            await context.SaveChangesAsync();

            var id = (await context.Set <Module>().FirstAsync(m => m.Name == moduleDto.Name &&
                                                              m.GroupId == moduleDto.GroupId &&
                                                              m.Description == m.Description &&
                                                              m.Deadline == moduleDto.Deadline &&
                                                              m.CreatedAt == moduleDto.CreatedAt)).Id;

            return(id);
        }