Пример #1
0
 public void Apply(BudgetCreated evnt)
 {
     _id = evnt.BudgetId;
     _name = evnt.Name;
     _owner = evnt.Owner;
     _currencyISOCode = evnt.CurrencyISOCode;
 }
Пример #2
0
 public LineExpenseChanged(Guid id, DateTime timestamp, LineId lineId, BudgetId budgetId, UserId updatedBy, Expense expense)
 {
     Id = id;
     Timestamp = timestamp;
     LineId = lineId;
     BudgetId = budgetId;
     UpdatedBy = updatedBy;
     Expense = expense;
 }
Пример #3
0
 public BudgetCreated(Guid id, DateTime timestamp, BudgetId budgetId, string name, UserId owner, string currencyISOCode)
 {
     Id = id;
     Timestamp = timestamp;
     BudgetId = budgetId;
     Name = name;
     Owner = owner;
     CurrencyISOCode = currencyISOCode;
 }
Пример #4
0
 public UserCreated(Guid id, DateTime timestamp, UserId userId, UserLoginInfo loginInfo, string userName, string password)
 {
     Id = id;
     Timestamp = timestamp;
     UserId = userId;
     LoginInfo = loginInfo;
     UserName = userName;
     Password = password;
 }
Пример #5
0
        public LineCreated(Guid id, DateTime timestamp, LineId lineId, BudgetId budgetId, UserId createdBy, Expense expense)
        {
            Id = id;
            Timestamp = timestamp;

            LineId = lineId;
            BudgetId = budgetId;
            Expense = expense;
            CreatedBy = createdBy;
        }
Пример #6
0
        protected override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            //var userId = Thread.CurrentPrincipal.Identity.Name;

            var userId = User.Identity.GetUserId();

            var users = ProjectionManager.GetUsersList();
            //var task = users.FindByIdAsync(userId);
            //var user = task.Result;
            try
            {
                var user = users.FindById(userId);
                //if (user == null)
                //    throw new Exception("Utente non è riconosciuto dal sistema");

                _userId = new UserId(userId);
            }
            catch
            {

            }
        }
Пример #7
0
        public void AllowAccess(UserId fromUser, UserId allowedUserId)
        {
            if (_state.CanAllowAccess(fromUser) == false)
                throw new Exception("User cannot allow access to budget");

            RaiseEvent(new BudgetAccessAllowed(Guid.NewGuid(), DateTime.Now, new BudgetId(Id), allowedUserId));
        }
Пример #8
0
 public void Create(BudgetId id, string name, UserId owner, string currencyISOCode)
 {
     RaiseEvent(new BudgetCreated(Guid.NewGuid(), DateTime.Now, id, name, owner, currencyISOCode));
 }
Пример #9
0
 public LineMarkedObsolete(Guid id, DateTime timestamp, LineId lineId, BudgetId budget, UserId userId, LineId obsoletedFor)
 {
     Id = id;
     Timestamp = timestamp;
     LineId = lineId;
     BudgetId = budget;
     UserId = userId;
     ObsoletedFor = obsoletedFor;
 }
Пример #10
0
 public UserPasswordChanged(Guid id, DateTime timestamp, UserId userId, string password)
 {
     Id = id;
     Timestamp = timestamp;
     UserId = userId;
     Password = password;
 }
Пример #11
0
        public void Create(LineId id, BudgetId budgetId, Expense expense, UserId createdBy)
        {
            if (string.IsNullOrEmpty(Id) == false)
                throw new Exception("line already exists");

            RaiseEvent(new LineCreated(Guid.NewGuid(), DateTime.Now, id, budgetId, createdBy, expense));
        }
Пример #12
0
 public IEnumerable<Budget> GetBudgetsUserCanView(UserId userId)
 {
     return _budgets.Values.Where(b => b.CanRead(userId));
 }
Пример #13
0
 internal bool CanRead(UserId userId)
 {
     return _allowedUsers.Contains(userId.ToString());
 }
Пример #14
0
 public UserLoginAdded(Guid id, DateTime timestamp, UserId userId, UserLoginInfo loginInfo)
 {
     Id = id;
     Timestamp = timestamp;
     UserId = userId;
     LoginInfo = loginInfo;
 }
Пример #15
0
        public void Create(UserId userId, UserLoginInfo loginInfo, string userName, string password)
        {
            if (string.IsNullOrEmpty(Id) == false)
                throw new Exception("User already exists");

            RaiseEvent(new UserCreated(Guid.NewGuid(), DateTime.Now, userId, loginInfo, userName, password));
        }
Пример #16
0
 public bool CanAllowAccess(UserId userId)
 {
     return _owner.Equals(userId);
 }
Пример #17
0
        public void Update(Expense expense, UserId updatedBy)
        {
            if (string.IsNullOrEmpty(Id))
                throw new Exception("line does not exists");

            RaiseEvent(new LineExpenseChanged(Guid.NewGuid(), DateTime.Now, _state.GetLineId(), _state.GetBudgetId(), updatedBy, expense));
        }
Пример #18
0
 public BudgetAccessAllowed(Guid id, DateTime timestamp, BudgetId budgetId, UserId allowedUserId)
 {
     Id = id;
     Timestamp = timestamp;
     BudgetId = budgetId;
     AllowedUserId = allowedUserId;
 }
Пример #19
0
        public void MarkObsolete(UserId userId, LineId obsoletedFor)
        {
            if (string.IsNullOrEmpty(Id) == false)
                throw new Exception("line does not exists");

            RaiseEvent(new LineMarkedObsolete(Guid.NewGuid(), DateTime.Now, _state.GetLineId(), _state.GetBudgetId(), userId, obsoletedFor));
        }