public async Task <bool> UpdateAsync(SizePrice item)
        {
            _context.SizePrice.Update(item);
            await _context.SaveChangesAsync();

            return(true);
        }
        public async Task <SizePrice> CreateAsync(SizePrice item)
        {
            item.Id = Guid.Empty;
            var result = await _context.SizePrice.AddAsync(item);

            await _context.SaveChangesAsync();

            return(result.Entity);
        }
        public async Task <bool> DeleteAsync(Guid id)
        {
            SizePrice sp = await _context.SizePrice.FindAsync(id);

            if (sp == null)
            {
                return(false);
            }
            _context.SizePrice.Remove(sp);
            await _context.SaveChangesAsync();

            return(true);
        }
        public async Task <IActionResult> EditSizePrice(SizePrice sp)// обработка формы редактирования размер/цена
        {
            try
            {
                await _repoSP.UpdateAsync(sp);

                return(RedirectToAction("DishInfo", new { id = sp.DishId }));
            }
            catch (Exception ex)
            {
                return(RedirectToAction("Index"));
            }
        }
        private ObservableCollection <SizePrice> CreateSizePrices()
        {
            ObservableCollection <SizePrice> sizePrices = new ObservableCollection <SizePrice>();
            SizePrice sizePrice;

            sizePrice = new SizePrice("S", "20.85");
            sizePrices.Add(sizePrice);

            sizePrice = new SizePrice("M", "24.85");
            sizePrices.Add(sizePrice);

            sizePrice = new SizePrice("L", "27.85");
            sizePrices.Add(sizePrice);

            return(sizePrices);
        }
Пример #6
0
        private void sizePriceListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (sizePriceListBox.SelectedItem != null)
            {
                // Setting en
                btnDeleteSizePrice.IsEnabled = true;
                btnUpdateSizePrice.IsEnabled = true;
                btnClearSizePrice.IsEnabled  = true;
                btnAddSizePrice.IsEnabled    = true;

                selectedFileNameSizePrice = sizePriceListBox.SelectedItem.ToString().Replace(".chel", "");
                sizePriceName.Text        = sizePriceListBox.SelectedItem.ToString().Replace(".chel", "");
                FlowDocument myFlowDoc = new FlowDocument();
                new Task(() =>
                {
                    Application.Current.Dispatcher.Invoke(new Action(delegate()
                    {
                        var lines = File.ReadLines(pathPriceSizeFormat + "\\" + sizePriceListBox.SelectedItem.ToString());
                        ObservableCollection <SizePrice> sizePrices = new ObservableCollection <SizePrice>();
                        SizePrice sizePrice;

                        foreach (var line in lines)
                        {
                            var strArr = line.Split("-");
                            if (strArr.Length != 2)
                            {
                                SP.WriteLogs(rtbLogsUploadProduct, "Data sai format! Vui lòng kiểm tra lại!");
                            }
                            SP.WriteLogs(rtbLogsUploadProduct, "Row data: " + strArr[0] + ", " + strArr[1]);
                            sizePrice = new SizePrice(strArr[0], strArr[1]);
                            sizePrices.Add(sizePrice);
                        }

                        this.sizePriceGrid.ItemsSource = sizePrices;
                    }));
                }).Start();
            }
            else
            {
                btnDeleteSizePrice.IsEnabled = false;
                btnUpdateSizePrice.IsEnabled = false;
                btnClearSizePrice.IsEnabled  = false;
                btnAddSizePrice.IsEnabled    = false;
            }
        }
Пример #7
0
        private void sizePriceGrid_AddingNewDataItem(object sender, GridViewAddingNewEventArgs e)
        {
            var sizePrice = new SizePrice();

            e.NewObject = sizePrice;
        }