/// <summary> // Multi Picture save /// </summary> /// <param name="images"></param> /// <param name="folderName"></param> /// <returns></returns> public async Task <List <SubjectForClass> > Create(List <IFormFile> images, string folderName) { List <SubjectForClass> pictures = new List <SubjectForClass>(); foreach (var image in images) { SubjectForClass picture = new SubjectForClass(); string path, fileName; Save(image, folderName, out path, out fileName); picture.FileName = fileName; if (path != "") { picture.VirtualPath = path; _context.SubjectForClass.Add(picture); try { await _context.SaveChangesAsync(); } catch (Exception) { return(null); } } pictures.Add(picture); } return(pictures); }
public async Task <Students> Register(Students student, string password) { byte[] passwordHash, passwordSalt; CreatePasswordHash(password, out passwordHash, out passwordSalt); student.PasswordHash = passwordHash; student.PasswordSalt = passwordSalt; await _context.Students.AddAsync(student); //save user await _context.SaveChangesAsync(); //save changes back to the database return(student); }
public async Task <bool> SaveAll() { return(await _context.SaveChangesAsync() > 0); }