Exemplo n.º 1
0
        private async Task <bool> OnSave()
        {
            if (_editing)
            {
                return(await UpdateBox());
            }
            IsBusy = true;
            bool success = false;

            ValidationResult result = Validator.ValidateName(_boxName);

            ErrBoxName = result.Message;

            if (!result.Error)
            {
                //String roomId = null;

                //if (SelectedRoom != null)
                //     roomId = SelectedRoom.Id;

                Box newBox = new Box(_boxName, _boxPriority, SelectedRoom.id);
                // await _connectionService.CreateBox(_moveId, newBox);
                newBox.id = await BoxDAO.CreateBox(_moveId, newBox);

                if (string.IsNullOrEmpty(newBox.id))
                {
                    ErrBoxName = "Failed to add new box. Please try again";
                    IsBusy     = false;
                }
                else
                {
                    ErrBoxName = "Success!";
                    IsBusy     = false;
                    App.PopNavAsync();
                    success = true;
                }
            }
            IsBusy = false;
            return(success);
        }