public Version AddVersion(string name, IFormFile file) { Material material = _materialRepository.GetMaterialByName(name); Version newVersion; if (material != null) { newVersion = new Version { Material = material, UploadTime = DateTime.Now, Size = file.Length, VersionCounter = material.Versions.Count() + 1 }; string path = _config.GetValue <String>("FilesPath:Type:ProjectDirectory") + material.Name + "_v" + (material.Versions.Count() + 1); using (var fileStream = new FileStream(path, FileMode.Create)) { file.CopyToAsync(fileStream); fileStream.Flush(); } _versionRepository.AddVersion(newVersion); _versionRepository.Save(); return(newVersion); } return(null); }
public void UpdateVersion(Version version) { context.Entry(version).State = EntityState.Modified; }
public void DeleteVersion(int versionId) { Version version = context.Versions.Find(versionId); context.Versions.Remove(version); }
public void AddVersion(Version version) { context.Versions.Add(version); }