Пример #1
0
 public RequestModel Save(RequestModel requestModel)
 {
     if (requestModel.Equals(null))
     {
         return(null);
     }
     return(repository.Save(requestModel));
 }
Пример #2
0
        public IActionResult Save([FromBody] RequestModel element)
        {
            if (element.Equals(null))
            {
                return(BadRequest());
            }

            var request = requestService.Save(element);

            if (request.Equals(null))
            {
                return(NotFound());
            }

            return(Ok(Newtonsoft.Json.JsonConvert.SerializeObject(request)));
        }
Пример #3
0
        private void ExecuteCommand(object sender, EventArgs e, string parentKey, string commandCode, object dataModel)
        {
            MainWindow UcHomeScreen = (MainWindow)UserControls[typeof(MainWindow).Name].Control;

            switch (commandCode)
            {
            case "Home":
            {
                ShowWelcomeScreen();
            }
            break;

            case "Back":
            {
                if (!string.IsNullOrEmpty(UserControls[parentKey].Previous))
                {
                    ShowPreviousControlOnPanel(parentKey);
                }
            }
            break;

            case "Next":
            {
                if (UcHomeScreen.CurrentPage is UcCreateReport)
                {
                    ShowProcessingPage();
                    Thread ViewItemMaster = new Thread(delegate()
                        {
                            UcCreateReport UcCreateReport = (UcCreateReport)UserControls[typeof(UcCreateReport).Name].Control;
                            if (UcCreateReport.ValidateModel())
                            {
                                DataTable dt = DataLayer.GetReportData(UcCreateReport.MreportModel);

                                if (dt != null)
                                {
                                    if (dt.Rows.Count > 0)
                                    {
                                        UcReport UcReport = (UcReport)UserControls[typeof(UcReport).Name].Control;
                                        UcReport.LoadReport(dt, UcCreateReport.MreportModel);
                                        ShowUserControlOnPanel(UcReport);
                                    }
                                    else
                                    {
                                        MessageBox.Show("No data found in database for the applied filter");
                                        ShowParentonPanel(parentKey);
                                    }
                                }
                                else
                                {
                                    MessageBox.Show("No data found in database for the applied filter");
                                    ShowParentonPanel(parentKey);
                                }
                            }
                            else
                            {
                                MessageBox.Show("Item must not be empty and date should be valid if used");
                                ShowParentonPanel(parentKey);
                            }
                        });
                    ViewItemMaster.Start();
                }
            }
            break;

            case "ViewItemMaster":
            {
                ClStockitem = new ObservableCollection <MStockitem>();
                ShowProcessingPage();
                Thread ViewItemMaster = new Thread(delegate()
                    {
                        ClStockitem = LoadCollectionData();
                        UcItemMaster UcItemMaster = (UcItemMaster)UserControls[typeof(UcItemMaster).Name].Control;
                        UcItemMaster.ClStockitem  = ClStockitem;
                        ShowUserControlOnPanel(UcItemMaster);
                    });
                ViewItemMaster.Start();
            }
            break;

            case "ViewStock":
            {
                ClStockitem = new ObservableCollection <MStockitem>();
                ShowProcessingPage();
                Thread ViewStock = new Thread(delegate()
                    {
                        if (GetItemList().Any())
                        {
                            ClStockitem          = LoadCollectionData(true);
                            UcStocks UcStocks    = UcStocks = (UcStocks)UserControls[typeof(UcStocks).Name].Control;
                            UcStocks.ClStockitem = ClStockitem;
                            ShowUserControlOnPanel(UcStocks);
                        }
                        else
                        {
                            MessageBox.Show("No item found ,please add items first");
                            ShowParentonPanel(parentKey);
                        }
                    });
                ViewStock.Start();
            }
            break;

            case "ViewReport":
            {
                ShowProcessingPage();
                Thread ViewReport = new Thread(delegate()
                    {
                        if (GetItemList().Any())
                        {
                            UcCreateReport UcCreateReport = (UcCreateReport)UserControls[typeof(UcCreateReport).Name].Control;
                            UcCreateReport.MreportModel   = new MreportModel();
                            ShowUserControlOnPanel(UcCreateReport);
                        }
                        else
                        {
                            MessageBox.Show("No item found ,please add items first"); ShowParentonPanel(parentKey);
                        }
                    });
                ViewReport.Start();
            }
            break;

            case "ActionFromItemMaster":
            {
                UcItemMaster UcItemMaster = (UcItemMaster)UserControls[typeof(UcItemMaster).Name].Control;
                if (dataModel.ToString().Equals(UcItemMaster.EAction.AddNewItem.ToString()))
                {
                    UcUpdateItem UcUpdateItem = (UcUpdateItem)UserControls[typeof(UcUpdateItem).Name].Control;
                    UcUpdateItem.resetPage();

                    if (ClStockitem.Any())
                    {
                        UcUpdateItem.LastItemId = ClStockitem.OrderBy(i => i.ItemNo).Last().ItemNo;
                    }
                    else
                    {
                        UcUpdateItem.LastItemId = 0;
                    }
                    UcUpdateItem.ClStockitem = ClStockitem;
                    ShowUserControlOnPanel(UcUpdateItem);
                }

                else if (dataModel.ToString().Equals(UcItemMaster.EAction.UpdateExistingitem.ToString()))
                {
                    if (ClStockitem.Any())
                    {
                        UcModifyExistingItem UcModifyExistingItem = (UcModifyExistingItem)UserControls[typeof(UcModifyExistingItem).Name].Control;
                        UcModifyExistingItem.CurrentModel = null;

                        UcModifyExistingItem.ClStockitem = ClStockitem;
                        ShowUserControlOnPanel(UcModifyExistingItem);
                    }
                    else
                    {
                        MessageBox.Show("Please add item first");
                    }
                }
            }
            break;

            case "AddNewItem":
            {
                UcUpdateItem UcUpdateItem = (UcUpdateItem)UserControls[typeof(UcUpdateItem).Name].Control;

                ShowProcessingPage();
                Thread THAddNewItem = new Thread(delegate()
                    {
                        if (DataLayer.InsertItemIntoMaster(UcUpdateItem.CreateNewModel()))
                        {
                            // ClStockitem.Add(UcUpdateItem.CreateNewModel());

                            UcItemMaster UcItemMaster = (UcItemMaster)UserControls[typeof(UcItemMaster).Name].Control;
                            UcItemMaster.ClStockitem  = LoadCollectionData();
                            ShowUserControlOnPanel(UcItemMaster);
                        }
                        else
                        {
                            MessageBox.Show("Adding Item Failed"); ShowParentonPanel(parentKey);
                            ShowParentonPanel(parentKey);
                        }
                    });
                THAddNewItem.Start();
            }
            break;

            case "UpdateExistingItem":
            {
                UcModifyExistingItem UcModifyExistingItem = (UcModifyExistingItem)UserControls[typeof(UcModifyExistingItem).Name].Control;

                ShowProcessingPage();
                Thread UpdateExistingItem = new Thread(delegate()
                    {
                        if (DataLayer.UpdateItemInMaster(UcModifyExistingItem.CurrentModel))
                        {
                            ClStockitem = LoadCollectionData();
                            UcItemMaster UcItemMaster = (UcItemMaster)UserControls[typeof(UcItemMaster).Name].Control;
                            UcItemMaster.ClStockitem  = ClStockitem;
                            ShowUserControlOnPanel(UcItemMaster);
                        }
                        else
                        {
                            MessageBox.Show("Update Item Failed");
                            ShowParentonPanel(parentKey);
                        }
                    });
                UpdateExistingItem.Start();
            }
            break;

            case "DeleteExistingItem":
            {
                UcModifyExistingItem UcModifyExistingItem = (UcModifyExistingItem)UserControls[typeof(UcModifyExistingItem).Name].Control;
                ShowProcessingPage();
                Thread DeleteExistingItem = new Thread(delegate()
                    {
                        if (DataLayer.DeleteItemFromMaster(UcModifyExistingItem.CurrentModel))
                        {
                            ClStockitem = LoadCollectionData();
                            UcItemMaster UcItemMaster = (UcItemMaster)UserControls[typeof(UcItemMaster).Name].Control;
                            UcItemMaster.ClStockitem  = ClStockitem;
                            ShowUserControlOnPanel(UcItemMaster);
                        }
                        else
                        {
                            MessageBox.Show("Delete Item Failed");
                            ShowParentonPanel(parentKey);
                        }
                    });
                DeleteExistingItem.Start();
            }
            break;

            case "UpdateStock":
            {
                ShowProcessingPage();
                Thread UpdateStock = new Thread(delegate()
                    {
                        var ClstockToBeUpdated = ((ObservableCollection <MStockitem>)dataModel).Where(i => i.IsChanged).ToList();

                        var LastItem = ClstockToBeUpdated.Last();

                        foreach (var RequestModel in ClstockToBeUpdated)
                        {
                            if (DataLayer.InsertItemIntoDetail(RequestModel))
                            {
                                if (RequestModel.Equals(LastItem))
                                {
                                    UcStocks UcStocks    = (UcStocks)UserControls[typeof(UcStocks).Name].Control;
                                    UcStocks.ClStockitem = LoadCollectionData(true);
                                    ShowUserControlOnPanel(UcStocks);
                                }
                            }
                            else
                            {
                                MessageBox.Show("Action Failed");
                                ShowParentonPanel(parentKey);
                                break;
                            }
                        }
                    });
                UpdateStock.Start();
            }
            break;

            default:
                break;
            }
        }