public Description Create(long userId, Description toAdd) { Description toRet; using (var tran = new TransactionScope()) { //Check if previously exists var predicate = PredicateBuilder.True <Description>(); predicate = predicate.And(p => p.LanguageId == toAdd.LanguageId); predicate = predicate.And(p => p.Parent == toAdd.Parent); predicate = predicate.And(p => p.Code == toAdd.Code); var toCheck = LoadSearch(userId, predicate).SingleOrDefault(); if (toCheck != null) { throw new BusinessException("AlreadyExists1", "lblDescription"); } toRet = _repository.Create(toAdd); //Force cash refresh for all module entries CacheHelper.Clear(Module); BlLog.Log(userId, Module, "Create description", "DescriptionCreated", new object[] { toAdd.Parent, toAdd.Code, toAdd.LanguageId }); tran.Complete(); } return(toRet); }
public static string GetLatinDict(long userId, string token) { using (var tran = new TransactionScope(TransactionScopeOption.RequiresNew)) { string toRet; var repository = new ArDictRepository(); var predicate = PredicateBuilder.True <ArDict>(); predicate = predicate.And(p => p.Replacement == token.Trim()); var dictEntry = repository.LoadSearch(predicate).FirstOrDefault(); if (dictEntry != null) { //Increment occurance dictEntry.Occurance += 1; repository.Edit(dictEntry); BlLog.Log(userId, "Entity", "Edit arabic dictionnary", "ArabicDictModified", new object[] { dictEntry.Token, dictEntry.Replacement, dictEntry.Occurance }); toRet = dictEntry.Token; } else { toRet = ""; } tran.Complete(); return(toRet); } }
public static string GetAntiDict(long userId, string token) { using (var tran = new TransactionScope(TransactionScopeOption.RequiresNew)) { string toRet; var repository = new AntiDictRepository(); var dictEntry = repository.LoadSingle(token); if (dictEntry != null) { //Increment occurance dictEntry.Occurance += 1; repository.Edit(dictEntry); BlLog.Log(userId, "Entity", "Edit anti dictionnary", "AntiDictModified", new object[] { dictEntry.Token, dictEntry.Replacement, dictEntry.Occurance }); toRet = dictEntry.Replacement; } else { //Create empty dictionary entry for later management CreateEmptyEntry(userId, token); toRet = token; } tran.Complete(); return(toRet); } }
public static bool LogOut(long userId) { var user = LoadSingle(userId, true); //Add extra log out code BlLog.Log(userId, Module, "LogOut", "UserSuccessfulLogout", new object[] { user.UserName }); return(true); }
public bool Delete(long userId, Address toDelete) { using (var tran = new TransactionScope()) { var toRet = _repository.Delete(toDelete); BlLog.Log(userId, Module, "Delete address", "AddressDeleted", new object[] { toDelete.Sequence, toDelete.Entity.Pin, BlEntity.FormatFullName(toDelete.Entity) }); tran.Complete(); return(toRet); } }
public bool Delete(long userId, Help toDelete) { using (var tran = new TransactionScope()) { var toRet = _repository.Delete(toDelete); BlLog.Log(userId, Module, "Delete help", "HelpDeleted", new object[] { toDelete.Page, toDelete.Ctrl }); tran.Complete(); return(toRet); } }
public Help Edit(long userId, Help toEdit) { using (var tran = new TransactionScope()) { var toRet = _repository.Edit(toEdit); BlLog.Log(userId, Module, "Edit help", "HelpModified", new object[] { toEdit.Page, toEdit.Ctrl }); tran.Complete(); return(toRet); } }
public Help Create(long userId, Help toAdd) { using (var tran = new TransactionScope()) { var toRet = _repository.Create(toAdd); BlLog.Log(userId, Module, "Create help", "HelpCreated", new object[] { toAdd.Page, toAdd.Ctrl }); tran.Complete(); return(toRet); } }
public Document Edit(long userId, Document toEdit) { using (var tran = new TransactionScope()) { var toRet = _repository.Edit(toEdit); BlLog.Log(userId, Module, "Edit document", "DocumentModified", new object[] { toEdit.Name, toEdit.Reference }); tran.Complete(); return(toRet); } }
public bool Delete(long userId, Description toDelete) { using (var tran = new TransactionScope()) { var toRet = _repository.Delete(toDelete); BlLog.Log(userId, Module, "Delete description", "DescriptionDeleted", new object[] { toDelete.Parent, toDelete.Code, toDelete.LanguageId }); tran.Complete(); return(toRet); } }
public bool Delete(long userId, Entity toDelete) { using (var tran = new TransactionScope()) { var toRet = _repository.Delete(toDelete); BlLog.Log(userId, Module, "Delete entity", "EntityDeleted", new object[] { toDelete.Pin }); tran.Complete(); return(toRet); } }
public bool Delete(long userId, Branch toDelete) { using (var tran = new TransactionScope()) { var toRet = _repository.Delete(toDelete); BlLog.Log(userId, Module, "Delete branch", "BranchDeleted", new object[] { toDelete.Id }); tran.Complete(); return(toRet); } }
public Branch Edit(long userId, Branch toEdit) { using (var tran = new TransactionScope()) { var toRet = _repository.Edit(toEdit); BlLog.Log(userId, Module, "Delete branch", "BranchModified", new object[] { toEdit.Id }); tran.Complete(); return(toRet); } }
public Comment Create(long userId, Comment toAdd) { using (var tran = new TransactionScope()) { var toRet = _repository.Create(toAdd); BlLog.Log(userId, Module, "Create comment", "CommentCreated", new object[] { toAdd.Text.ManageTextLength(100), toAdd.Reference }); tran.Complete(); return(toRet); } }
public Company Edit(long userId, Company toEdit) { using (var tran = new TransactionScope()) { var toRet = _repository.Edit(toEdit); BlLog.Log(userId, Module, "Delete company", "CompanyModified", new object[] { toEdit.Id }); tran.Complete(); return(toRet); } }
public Document Create(long userId, Document toAdd) { using (var tran = new TransactionScope()) { var toRet = _repository.Create(toAdd); BlLog.Log(userId, Module, "Create document", "DocumentCreated", new object[] { toAdd.Name, toAdd.Reference }); tran.Complete(); return(toRet); } }
public Description Edit(long userId, Description toEdit) { using (var tran = new TransactionScope()) { var toRet = _repository.Edit(toEdit); BlLog.Log(userId, Module, "Edit description", "DescriptionModified", new object[] { toEdit.Parent, toEdit.Code, toEdit.LanguageId }); tran.Complete(); return(toRet); } }
public Employee Edit(long userId, Employee toEdit) { using (var tran = new TransactionScope()) { var toRet = _repository.Edit(toEdit); BlLog.Log(userId, Module, "Edit employee", "EmployeeModified", new object[] { toEdit.Entity.Pin, BlEntity.FormatFullName(toEdit.Entity) }); tran.Complete(); return(toRet); } }
public Role Create(long userId, Role toAdd) { using (var tran = new TransactionScope()) { var toRet = _repository.Create(toAdd); BlLog.Log(userId, Module, "Create role", "RoleCreated", new object[] { toAdd.Code }); tran.Complete(); return(toRet); } }
public bool Delete(long userId, Permission toDelete) { using (var tran = new TransactionScope()) { var toRet = _repository.Delete(toDelete); BlLog.Log(userId, Module, "Delete permission", "PermissionDeleted", new object[] { toDelete.Id, toDelete.Module.Id }); tran.Complete(); return(toRet); } }
public Company Create(long userId, Company toAdd) { using (var tran = new TransactionScope()) { var toRet = _repository.Create(toAdd); BlLog.Log(userId, Module, "Delete company", "CompanyCreated", new object[] { toAdd.Id }); tran.Complete(); return(toRet); } }
public Menu Edit(long userId, Menu toEdit) { using (var tran = new TransactionScope()) { var toRet = _repository.Edit(toEdit); BlLog.Log(userId, Module, "Edit menu", "MenuModified", new object[] { toEdit.DescriptionCode, toEdit.Module.Id }); tran.Complete(); return(toRet); } }
public Permission Edit(long userId, Permission toEdit) { using (var tran = new TransactionScope()) { var toRet = _repository.Edit(toEdit); BlLog.Log(userId, Module, "Edit permission", "PermissionModified", new object[] { toEdit.Id, toEdit.Module.Id }); tran.Complete(); return(toRet); } }
public bool Delete(long userId, Menu toDelete) { using (var tran = new TransactionScope()) { var toRet = _repository.Delete(toDelete); BlLog.Log(userId, Module, "Delete menu", "MenuDeleted", new object[] { toDelete.DescriptionCode, toDelete.Module.Id }); tran.Complete(); return(toRet); } }
public Menu Create(long userId, Menu toAdd) { using (var tran = new TransactionScope()) { var toRet = _repository.Create(toAdd); BlLog.Log(userId, Module, "Create menu", "MenuCreated", new object[] { toAdd.DescriptionCode, toAdd.Module.Id }); tran.Complete(); return(toRet); } }
public bool Delete(long userId, User toDelete) { using (var tran = new TransactionScope()) { var toRet = _repository.Delete(toDelete); BlLog.Log(userId, Module, "Delete user", "UserDeleted", new object[] { toDelete.UserName }); tran.Complete(); return(toRet); } }
public User Create(long userId, User toAdd) { using (var tran = new TransactionScope()) { var toRet = _repository.Create(toAdd); BlLog.Log(userId, Module, "Create user", "UserCreated", new object[] { toAdd.UserName }); tran.Complete(); return(toRet); } }
public Permission Create(long userId, Permission toAdd) { using (var tran = new TransactionScope()) { PreSave(userId, ref toAdd, Enumerations.ActionMode.Add); var toRet = _repository.Create(toAdd); BlLog.Log(userId, Module, "Create permission", "PermissionCreated", new object[] { toAdd.Code, toAdd.Module.Id }); tran.Complete(); return(toRet); } }
public UserVm ProfileSave(long userId, UserVm toEdit) { using (var tran = new TransactionScope()) { var user = LoadSingle(toEdit.User.Id, true); if (toEdit.ChangePassword) { if (!Cryptography.ComputeToHash(toEdit.OldPassword).SequenceEqual(user.Password)) { throw new BusinessException("WrongOldPassword"); } if (!Cryptography.ComputeToHash(toEdit.NewPassword).SequenceEqual(Cryptography.ComputeToHash(toEdit.ConfirmPassword))) { throw new BusinessException("NewPasswordDoesNotmatchConfirmation"); } user.LastPasswordUpdate = BlCommon.GetServerDateTime(); if (user.PasswordHistory != "") { var oldPasswordList = CheckEmpty.String(user.PasswordHistory).Split(','); foreach (var pass in oldPasswordList) { if (Cryptography.ComputeToHash(toEdit.NewPassword).SequenceEqual(Convert.FromBase64String(pass))) { throw new BusinessException("NewPasswordFrequentlyUsed"); } } } user.PasswordHistory += user.PasswordHistory == "" ? "" : ","; user.PasswordHistory += Convert.ToBase64String(user.Password); var historyLength = BlCode.LoadSingle(userId, "_System", "PasswordHistroyLength").Value1; if (user.PasswordHistory.Split(',').Length > Convert.ToInt32(historyLength)) { var newPasswordHistroy = user.PasswordHistory.Split(',').ToList(); newPasswordHistroy.RemoveAt(0); user.PasswordHistory = string.Join(",", newPasswordHistroy); } user.Password = Cryptography.ComputeToHash(toEdit.NewPassword); toEdit.ChangePassword = false; } user.UserName = toEdit.User.UserName; user.LanguageId = Convert.ToInt16(toEdit.User.LanguageId); user.PageSize = Convert.ToInt16(toEdit.User.PageSize); Edit(userId, user); //Force cash refresh for module entry CacheHelper.Clear(Module + "_" + user.Id.ToUiString()); BlLog.Log(userId, Module, "Profile change", "UserProfileModified", new object[] { user.UserName }); tran.Complete(); return(toEdit); } }
public void ResetPassword(long userId, long toResetUserId) { using (var tran = new TransactionScope()) { var defaultPassword = BlCode.LoadSingle(userId, "_System", "DefaultPassword").Value1; var toResetUser = LoadSingle(toResetUserId); toResetUser.Password = Cryptography.ComputeToHash(defaultPassword); toResetUser.MustChangePassword = true; BlLog.Log(userId, Module, "Password reset", "UserPasswordReset", new object[] { toResetUser.UserName }); tran.Complete(); } }