コード例 #1
0
        private async void OnDeleteClick(WpfRawMaterial wpfRawMaterial)
        {
            if (wpfRawMaterial == null)
            {
                return;
            }

            var    rawMaterialToDb = RestproMapper.MapWpfRawMaterialToRawMaterial(wpfRawMaterial);
            string errorMessage    = null;

            try
            {
                RawMaterials.Remove(wpfRawMaterial);
                if (wpfRawMaterial.Id != 0)
                {
                    _unitOfWork.RawMaterials.FakeDelete(rawMaterialToDb);
                }
                await dialogCoordinator.ShowMessageAsync(this, "Success", "Raw Material Deleted Successfully. Good Bye :(");
            }
            catch (Exception e)
            {
                Debug.WriteLine(e);
                errorMessage = e.Message;
            }

            if (errorMessage == null)
            {
                return;
            }

            await dialogCoordinator
            .ShowMessageAsync(this, "Error"
                              , "Fatal Error Occured. You're Screwed!\n" +
                              errorMessage);
        }