Example #1
0
 public void RaiseSalary(EmployeeId id, decimal amount)
 {
     _store.DatabaseCommands.Patch($"employees/{id}", new ScriptedPatchRequest
     {
         Script = $"this.Salary += {amount.ToInvariantString()};"
     });
 }
 public RaiseEmployeeSalaryCommand(
     EmployeeId id, 
     decimal amount
     ) : base(id)
 {
     Amount = amount;
 }
 public EmployeeSalaryRaisedEvent(
     EmployeeId employeeId, 
     decimal amount
     ) : base(employeeId)
 {
     Amount = amount;
 }
Example #4
0
 public Employee Load(EmployeeId id)
 {
     using (var session = _store.OpenSession())
     {
         return session.Load<Employee>($"employees/{id}");
     }
     
 }
Example #5
0
 public RegisterEmployeeCommand(
     EmployeeId id,
     FullName name,
     decimal initialSalary
     ) : base(id)
 {
     Name = name;
     InitialSalary = initialSalary;
 }
Example #6
0
 public EmployeeRegisteredEvent(
     EmployeeId employeeId,
     FullName name, 
     decimal initialSalary
     ) : base(employeeId)
 {
     Name = name;
     InitialSalary = initialSalary;
 }
 public void UpdateHomeAddress(EmployeeId id, Address homeAddress)
 {
     var employee = _data[id];
     _data[id] = new Employee(
         employee.Id,
         employee.Name,
         homeAddress,
         employee.Salary
         );
 }
 public void RaiseSalary(EmployeeId id, decimal amount)
 {
     var employee = _data[id];
     _data[id] = new Employee(
         employee.Id,
         employee.Name,
         employee.HomeAddress,
         employee.Salary + amount
         );
  }
Example #9
0
 public void CreateEmployee(EmployeeId id, FullName name, decimal initialSalary)
 {
     using (var session = _store.OpenSession())
     {
         var employee = new Employee(id, name, 
             Address.NotInformed, 
             initialSalary
             );
         session.Store(employee);
         session.SaveChanges();
     }
 }
Example #10
0
 public void UpdateHomeAddress(EmployeeId id, Address homeAddress)
 {
     var ro = RavenJObject.FromObject(homeAddress, _serializer);
     
     _store.DatabaseCommands.Patch($"employees/{id}", new[]
     {
         new PatchRequest
         {
             Type = PatchCommandType.Set,
             Name = "HomeAddress",
             Value = ro
         }
     });
 }
Example #11
0
 protected EmployeeEvent(EmployeeId employeeId)
 {
     EmployeeId = employeeId;
 }
Example #12
0
 protected EmployeeCommand(EmployeeId id)
 {
     Id = id;
 }
 public void CreateEmployee(EmployeeId id, FullName name, decimal initialSalary)
 {
     _data.Add(id, new Employee(id, name, Address.NotInformed, initialSalary));
 }
Example #14
0
 public bool IsRegistered(EmployeeId id)
 {
     var lid = $"employees/{id}";
     return _store.DatabaseCommands.Head(lid) != null;
 }
 public bool IsRegistered(EmployeeId id)
 {
     return (_data.ContainsKey(id));
 }
 public FailedToRegisterEmployeeEvent(EmployeeId employeeId) : base(employeeId)
 {}
 public Employee Load(EmployeeId id)
 {
     return _data[id];
 }