public RawMaterialsListViewModel()
        {
            if (DesignerProperties.GetIsInDesignMode(
                new System.Windows.DependencyObject())) return;

            try
            {
                var rawMaterials = db.RawMaterials.ToList();
                RawMaterials = new ObservableCollection<RawMaterial>(rawMaterials);
            }
            catch (Exception ex)
            {
                logger.Error(ex.Message.ToString());
            }

            _newRawMaterial = new RawMaterial();
            _searchResults = new ObservableCollection<RawMaterial>();

            DeleteRawMaterialCommand = new RelayCommand<RawMaterial>(onDeleteRawMaterial);
            UpdateRawMaterialCommand = new RelayCommand<RawMaterial>(onUpdateRawMaterial);
            AddRawMaterialCommand = new RelayCommand<RawMaterial>(onAddRawMaterial);
            FindRawMaterialsCommand = new RelayCommand<string>(onFindRawMaterials);
        }
        public void onDeleteRawMaterial(RawMaterial rawMat)
        {
            if (rawMat != null)
            {
                MessageBoxResult messageBoxResult = System.Windows.MessageBox.Show("Are you sure you wish to delete this rawMaterial?", "Confirm Delete", System.Windows.MessageBoxButton.YesNo);

                if (messageBoxResult == MessageBoxResult.Yes)
                {
                    int rawMaterialid = rawMat.rawMaterialsID;
                    RawMaterial rawMatToRemove = (RawMaterial)RawMaterials.Single(r => r.rawMaterialsID == rawMaterialid);

                    db.RawMaterials.Remove(rawMatToRemove);
                    db.SaveChanges();
                    RawMaterials = UpdateRawMaterialsCollection(RawMaterials);
                }
            }
        }
        public void onUpdateRawMaterial(RawMaterial rawMat)
        {
            var rawMaterial = rawMat;

            if (rawMaterial != null)
            {
                db.Entry(rawMaterial).State = EntityState.Modified;
                db.SaveChanges();
                RawMaterials = UpdateRawMaterialsCollection(RawMaterials);

                MessageBoxResult msgBox = MessageBox.Show("Changes Saved", "Success");

            }
        }
        public void onAddRawMaterial(RawMaterial rawMat)
        {
            var newRawMaterial = rawMat;

            if (newRawMaterial != null)
            {
                db.RawMaterials.Add(newRawMaterial);
                db.SaveChanges();
                RawMaterials = UpdateRawMaterialsCollection(RawMaterials);
                MessageBoxResult msgBox = MessageBox.Show("RawMaterial Added", "Success");
            }
        }