Exemplo n.º 1
0
 public FinishedState(Customer customer, CustomerEvents customerEvents, Spawner spawner, float point)
 {
     _customer       = customer;
     _customerEvents = customerEvents;
     _point          = point;
     _spawner        = spawner;
 }
Exemplo n.º 2
0
    void Awake()
    {
        _spawner        = GetComponentInParent <Spawner>();
        _customerEvents = GetComponent <CustomerEvents>();

        var waitingState  = new WaitingState(this, _customerEvents);
        var buyingState   = new BuyingState(_buyTime, this, _customerEvents);
        var finishedState = new FinishedState(this, _customerEvents, _spawner, point);
        var deadState     = new DeadState(this, _spawner);

        _stateMachine = new StateMachine();

        At(waitingState, buyingState, IsCustomerCanBuy());
        At(buyingState, waitingState, NotIsCustomerCanBuy());
        At(waitingState, deadState, IsDead());
        At(buyingState, deadState, IsDead());
        At(buyingState, finishedState, IsFinishedBuying());

        _stateMachine.SetState(waitingState);

        void At(IState from, IState to, Func <bool> condition) => _stateMachine.AddTransition(from, to, condition);
        Func <bool> IsCustomerCanBuy() => () => _canBuy;
        Func <bool> NotIsCustomerCanBuy() => () => !_canBuy;
        Func <bool> IsFinishedBuying() => () => _finishedBuying;
        Func <bool> IsDead() => () => _isDead;
    }
Exemplo n.º 3
0
 public override void Handle(CustomerEvents.Created message)
 {
     CustomerDto dto = this.Load(message.CustomerId);
     if (dto != null) throw new Exception("Item with the same Id already created!");
     dto = new CustomerDto();
     dto.CustomerId = message.CustomerId;
     this.Save(dto);
 }
 void Awake()
 {
     _customer       = GetComponentInParent <Customer>();
     _customerEvents = GetComponentInParent <CustomerEvents>();
     _textMeshPro    = GetComponentInChildren <TextMeshProUGUI>();
     _slider         = GetComponentInChildren <Slider>();
     _rectTransform  = GetComponent <RectTransform>();
 }
Exemplo n.º 5
0
        public CustomerEvents Execute(GetCustomerById query)
        {
            var result = new CustomerEvents()
            {
                Events = CustomerRepository.GetCustomers(query.Id)
            };

            return(result);
        }
Exemplo n.º 6
0
 public void Post([FromBody] delCustEvent cusEvent)
 {
     if (cusEvent != null)
     {
         CustomerEvents sub = new CustomerEvents
         {
             Title       = cusEvent.Title,
             Description = cusEvent.Description,
             Date        = cusEvent.Date
         };
         customerMediator.InsertEvent(sub, cusEvent.cusId);
     }
 }
Exemplo n.º 7
0
        /// <summary>
        /// Inserts an Event for a specified customer
        /// </summary>
        /// <param name="cusEvent">The event to be inserted</param>
        /// <param name="cusId">The unique customer ID</param>
        /// <returns>An event</returns>
        public async Task <CustomerEvents> InsertEvent(CustomerEvents cusEvent, int cusId)
        {
            using (var connection = new SqlConnection(this.connectionString))
            {
                var cmd = new SqlCommand("INSERT INTO [dbo].[CustomerEvents] (Title, EventDescription, EventDate, customerId) "
                                         + "VALUES (@title, @eventDescription, @eventDate, @customerId)", connection);
                cmd.Parameters.AddWithValue("@title", SqlDbType.VarChar).Value            = cusEvent.Title;
                cmd.Parameters.AddWithValue("@eventDescription", SqlDbType.VarChar).Value = cusEvent.Description;
                cmd.Parameters.AddWithValue("@eventDate", SqlDbType.Date).Value           = cusEvent.Date;
                cmd.Parameters.AddWithValue("@customerId", SqlDbType.Int).Value           = cusId;

                await connection.OpenAsync();

                int result = await cmd.ExecuteNonQueryAsync();
            }
            return(cusEvent);
        }
Exemplo n.º 8
0
 public async Task <CustomerEvents> InsertEvent(CustomerEvents cusEvent, int cusId)
 {
     return(await customerDataAccess.InsertEvent(cusEvent, cusId));
 }
Exemplo n.º 9
0
 void Awake()
 {
     _customerEvents   = GetComponent <CustomerEvents>();
     _audioSource      = GetComponent <AudioSource>();
     _audioSource.clip = _soldSound;
 }
Exemplo n.º 10
0
 public BuyingState(float buyTime, Customer customer, CustomerEvents customerEvents)
 {
     _buyTime = buyTime;
     _customer = customer;
     _customerEvents = customerEvents;
 }
Exemplo n.º 11
0
 public override void Handle(CustomerEvents.PaymentTypeRemoved message)
 {
     CustomerDto dto = this.Load(message.CustomerId);
     dto.PaymentTypeIdList.Remove(message.PaymentTypeId);
     this.Save(dto);
 }
Exemplo n.º 12
0
 public override void Handle(CustomerEvents.BankAccountRemoved message)
 {
     CustomerDto dto = this.Load(message.CustomerId);
     dto.BankAccountList.Remove(message.BankAccount);
     this.Save(dto);
 }
Exemplo n.º 13
0
 public override void Handle(CustomerEvents.NoteChanged message)
 {
     CustomerDto dto = this.Load(message.CustomerId);
     dto.Note = message.Note;
     this.Save(dto);
 }
 public void When(CustomerEvents.NameChanged e)
 {
     this.Name = e.Name;
 }
Exemplo n.º 15
0
 public async Task <CustomerEvents> InsertEvent(CustomerEvents cusEvent, int cusId)
 {
     return(await customerRepository.InsertEvent(cusEvent, cusId));
 }
 public void When(CustomerEvents.PaymentTypeRemoved e)
 {
     this.PaymentTypeIdList.Remove(e.PaymentTypeId);
 }
Exemplo n.º 17
0
 public WaitingState(Customer customer, CustomerEvents customerEvents)
 {
     _customer       = customer;
     _customerEvents = customerEvents;
 }
 public void When(CustomerEvents.BankAccountRemoved e)
 {
     this.BankAccountList.Remove(e.BankAccount);
 }
 public void When(CustomerEvents.BankAccountAdded e)
 {
     this.BankAccountList.Add(e.BankAccount);
 }
 public void When(CustomerEvents.NoteChanged e)
 {
     this.Note = e.Note;
 }
 public void When(CustomerEvents.CompanyRemoved e)
 {
     this.CompanyId = e.CompanyId;
 }
Exemplo n.º 22
0
 public override void Handle(CustomerEvents.CompanyRemoved message)
 {
     CustomerDto dto = this.Load(message.CustomerId);
     dto.CompanyId = message.CompanyId;
     this.Save(dto);
 }
 public void When(CustomerEvents.PaymentTypeAdded e)
 {
     this.PaymentTypeIdList.Add(e.PaymentTypeId);
 }
 public void When(CustomerEvents.Created e)
 {
     this.CustomerId = e.CustomerId;
 }