public async Task <bool> SaveFile(JObject data) { //var user = "******"; //var version = "_asV_"; dynamic codeDto = data; int id = codeDto.Id; bool checkIn = codeDto.CheckIn; string path = codeDto.Path; string codeContent = codeDto.Code; string comment = codeDto.Comment; path = path.Replace(Config.UrlDelimeter, Helper.RootUrl); var code = ContentManagementContext.MasterDataKeyValues.FirstOrDefault(sr => sr.Id == id); if (code == null) { throw new KhodkarInvalidException(LanguageManager.ToAsErrorMessage(ExceptionKey.CodeNotFound)); } if (code.EditMode) { SourceControl.CheckCodeCheckOute(code); } AuthorizeManager.SetAndCheckModifyAndAccessRole(code, null, false); if (await FileSystemManager.FileExistAsync(AuthorizeManager .AuthorizeActionOnPath(path, ActionKey.WriteToDisk))) { code.Version++; await ContentManagementContext.SaveChangesAsync(); await SourceControl.AddChange(path.Remove(path.LastIndexOf("/", StringComparison.Ordinal) + 1), path.Substring(path.LastIndexOf("/", StringComparison.Ordinal) + 1), codeContent, code.Version, comment); //var userIndex = path.IndexOf(user, StringComparison.Ordinal); //var endSourceControlStringIndex = path.LastIndexOf(".", StringComparison.Ordinal); //if (userIndex > 0 && // path.IndexOf(version, StringComparison.Ordinal) > 0) //{ // path = path.Remove(userIndex, endSourceControlStringIndex - userIndex); //} //else //{ if (checkIn) { await FileSystemManager.WriteAsync(path, codeContent); } //} //return await FileSystemManager.WriteAsync(path.Insert(path.LastIndexOf(".", StringComparison.Ordinal), // user+ CurrentUserManager.UserName.Replace("@", "[at]")+version+code.Version), codeContent); return(true); } throw new KhodkarInvalidException(LanguageManager.ToAsErrorMessage(ExceptionKey.CodeNotFound)); }