Example #1
0
        private async void UpdateTime()
        {
            using (MarkBusy())
            {
                if (_teensyBatDevice != null && _teensyBatDevice.IsConnected)
                {
                    UpdateTimeCommand command = new UpdateTimeCommand();
                    await command.Execute(_teensyBatDevice);

                    Refresh();
                }
            }
        }
Example #2
0
 private void TeensyBatDeviceOnPropertyChanged(object sender, PropertyChangedEventArgs propertyChangedEventArgs)
 {
     OnPropertyChanged(nameof(Titel));
     OnPropertyChanged(nameof(IsConnected));
     UpdateTimeCommand.RaiseCanExecuteChanged();
     if (_teensyBatDevice.IsConnected)
     {
         _refreshTimer.Change(Timeout.Infinite, Timeout.Infinite);
     }
     else
     {
         _refreshTimer.Change(1000, 1000);
     }
 }
Example #3
0
        public ICommandResult Handle(UpdateTimeCommand command)
        {
            command.Validate();
            if (!command.IsValid)
            {
                return(new GenericCommandResult(false, "Error: ", command.Notifications));
            }

            var time = new Time(command.Project_Id, command.User_Id, command.Started_at, command.Ended_at);

            time.Id = command.Time_Id;
            _repository.Update(time);

            return(new GenericCommandResult(true, "Create time with success!", time));
        }
        public JsonResult Update([FromBody] UpdateTimeCommand command,
                                 [FromServices] TimeHandler handler)
        {
            if (command is null)
            {
                return new JsonResult(NotFound())
                       {
                           StatusCode = 404
                       }
            }
            ;

            try
            {
                var time = (GenericCommandResult)handler.Handle(command);

                if (!time.Success)
                {
                    return new JsonResult(BadRequest())
                           {
                               StatusCode = 400,
                               Value      = new GenericCommandResult(false, time.Message, command.Notifications)
                           }
                }
                ;
                var data = (Time)time.Data;


                return(Json(new TimeDTO(data.Id, data.Project, data.User, data.Started_at, data.Ended_at)));
            }
            catch (Exception ex)
            {
                return(new JsonResult(BadRequest())
                {
                    StatusCode = 400,
                    Value = new GenericCommandResult(false, ex.Message, command.Notifications)
                });
            }
        }
    }