Ejemplo n.º 1
0
        private async void DeleteBook()
        {
            try
            {
                ErrorMsgVisibility = Visibility.Collapsed;
                if (SelectedBook == null)
                {
                    ErrorMsg           = Properties.Resources.SelectBookErrorMsg;
                    ErrorMsgVisibility = Visibility.Visible;
                    return;
                }

                var tx = AllOrderData.FirstOrDefault(t => t.BookId == SelectedBook.BookId && t.HasBook == 1);
                ///if the selected book has already been taken it will restrict the user from deleting it.
                ///User can delete this book only when all the book has returned or the user which has this book is deleted.
                if (tx != null)
                {
                    ErrorMsg           = "Cannot Delete this book.Someuser owns it\n Please delete that user or return the book";
                    ErrorMsgVisibility = Visibility.Visible;
                    return;
                }
                await _dataAccess.DeleteData(SelectedBook, Properties.Resources.DeleteBook);

                _log.Message("Deleteing Book having BookId: " + SelectedBook.BookId);
                GetBooks();
                InvokeBookUpdate();
                ClearAllField();
            }
            catch (System.Data.SqlClient.SqlException ex)
            {
                _log.Error(ex);
            }
        }
Ejemplo n.º 2
0
        private async void GetAllOrders()
        {
            Task <List <CheckOutModel> > task = Task.Run <List <CheckOutModel> >(() => {
                var t = _allPastOrderDataAccess.GetAllOrderData(Properties.Resources.GetAllOrders);
                return(t);
            });

            _log.Message("Getting All Orders Details from the database");
            var orderCollection = await task;

            AllOrderData.Clear();
            orderCollection.ForEach(_order => AllOrderData.Add(_order));
        }