public bool AddOperation(Guid userId, Guid operationId) { try { var userOperationBO = new UserOperationBO(); var userRole = userOperationBO.Get(this.ConnectionHandler, userId, operationId); if (userRole == null) { var userOperation = new UserOperation { UserId = userId, OperationId = operationId }; if (!userOperationBO.Insert(this.ConnectionHandler, userOperation)) { throw new Exception("خطایی در ذخیره عملیات کاربر وجود دارد"); } } return(true); } catch (KnownException ex) { Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace); throw new KnownException(ex.Message, ex); } catch (Exception ex) { Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace); throw new KnownException(ex.Message, ex); } }
public bool DeleteAssosiations(IConnectionHandler connectionHandler, User user) { UserOperationBO uoBO = new UserOperationBO(); List <UserOperation> oprationuser = uoBO.Where(connectionHandler, c => c.UserId == user.Id); if (oprationuser.Any()) { foreach (UserOperation item in oprationuser) { if (!uoBO.Delete(connectionHandler, item)) { throw new Exception("خطا در حذف کاربر"); } } } return(true); }