コード例 #1
0
        /// <inheritdoc/>
        public async Task CreateAsync(Application.Models.Class.Class newClass)
        {
            Class        classEntity = newClass.MapToFileEntity();
            List <Class> classes     = await RetrieveOrCreateClassesAsync();

            classes.Add(classEntity);
            await SaveChangesAsync(classes);
        }
コード例 #2
0
        /// <inheritdoc/>
        public async Task <ValidationMessage> UpdateAsync(Application.Models.Class.Class @class)
        {
            List <Class> classes = await RetrieveOrCreateClassesAsync();

            int index = classes.FindIndex(x => x.Id == @class.Id);

            if (index == -1)
            {
                return(new ValidationMessage(nameof(@class), "The class was not found"));
            }
            Class classEntity = @class.MapToFileEntity();

            classes[index] = classEntity;
            await SaveChangesAsync(classes);

            return(null);
        }