示例#1
0
        public void Delete(BaseDTO dtoName)
        {
            Type currentType = dtoName.GetType();

            if (currentType.Name.Equals("ProductDTO"))
            {
                ProductsDAL deleteProduct = new ProductsDAL();
                deleteProduct.DeleteProduct((dtoName as ProductDTO).ProductNewName);
                resultMessage = deleteProduct.GetCRUDResult();
            }
            if (currentType.Name.Equals("VendorDTO"))
            {
                VendorsDAL deleteVendor = new VendorsDAL();
                deleteVendor.DeleteVendor((dtoName as VendorDTO).VendorName);
                resultMessage = deleteVendor.GetCRUDResult();
            }
            if (currentType.Name.Equals("CategoryDTO"))
            {
                CategoriesDAL deleteCategory = new CategoriesDAL();
                deleteCategory.DeleteCategory((dtoName as CategoryDTO).CategoryName);
                resultMessage = deleteCategory.GetCRUDResult();
            }
            else
            {
                //MessageBox.Show("Pone stigna do tuk v update seckciqta");
            }
        }
示例#2
0
        public void Update(BaseDTO dtoName)
        {
            Type currentType = dtoName.GetType();

            if (currentType.Name.Equals("ProductDTO"))
            {
                ProductsDAL updateProduct = new ProductsDAL();
                updateProduct.UpdateProduct((dtoName as ProductDTO).ProductOldName,
                                            (dtoName as ProductDTO).ProductNewName,
                                            (dtoName as ProductDTO).CategoryName,
                                            (dtoName as ProductDTO).VendorName,
                                            (dtoName as ProductDTO).ProductPrice,
                                            (dtoName as ProductDTO).Quantity,
                                            (dtoName as ProductDTO).StoreName,
                                            (dtoName as ProductDTO).TownName);
                resultMessage = updateProduct.GetCRUDResult();
            }
            if (currentType.Name.Equals("VendorDTO"))
            {
                VendorsDAL updateVendor = new VendorsDAL();
                updateVendor.UpdateVendor((dtoName as VendorDTO).VendorOldName, (dtoName as VendorDTO).VendorName);
                resultMessage = updateVendor.GetCRUDResult();
            }
            if (currentType.Name.Equals("CategoryDTO"))
            {
                CategoriesDAL updateCategory = new CategoriesDAL();
                updateCategory.UpdateCategory((dtoName as CategoryDTO).CategoryOldName, (dtoName as CategoryDTO).CategoryName);
                resultMessage = updateCategory.GetCRUDResult();
            }
            else
            {
                //MessageBox.Show("Pone stigna do tuk v update seckciqta");
            }
        }
示例#3
0
        internal void Update(BaseDTO dto)
        {
            // при изменении на сервере, изменить в кеше
            Task <BaseDTO> t = _client.UpdateAsync(dto);

            t.ContinueWith(td =>
            {
                BaseDTO dtoFromServer = td.Result as BaseDTO;
                if (IfErrorShowMessage(dtoFromServer))
                {
                    return;
                }
                if (_dataSources.ContainsKey(dto.GetType()))
                {
                    ICachedData items = _dataSources[dto.GetType()];
                    items.Update(dto);
                }
            });
        }
示例#4
0
        public void Insert(BaseDTO dtoName)
        {
            Type currentType = dtoName.GetType();

            if (currentType.Name.Equals("ProductDTO"))
            {
                ProductsDAL newProduct = new ProductsDAL();
                if (newProduct.IsProductNameExistInDb((dtoName as ProductDTO).ProductNewName))
                {
                    resultMessage = BaseDAL.Messages(MessageFor.ItemExistInDatabase, "Product");
                }
                else
                {
                    newProduct.InsertNewProduct((dtoName as ProductDTO).ProductNewName,
                                                (dtoName as ProductDTO).CategoryName,
                                                (dtoName as ProductDTO).VendorName,
                                                (dtoName as ProductDTO).ProductPrice,
                                                (dtoName as ProductDTO).Quantity,
                                                (dtoName as ProductDTO).StoreName,
                                                (dtoName as ProductDTO).TownName);
                    resultMessage = newProduct.GetCRUDResult();
                }
            }
            if (currentType.Name.Equals("VendorDTO"))
            {
                VendorsDAL newVendor = new VendorsDAL();
                if (newVendor.IsVendorNameExistInDb((dtoName as VendorDTO).VendorName))
                {
                    resultMessage = BaseDAL.Messages(MessageFor.ItemExistInDatabase, "Vendor");
                }
                else
                {
                    newVendor.InsertNewVendor((dtoName as VendorDTO).VendorName);
                    resultMessage = newVendor.GetCRUDResult();
                }
            }
            if (currentType.Name.Equals("CategoryDTO"))
            {
                CategoriesDAL newCategory = new CategoriesDAL();
                if (newCategory.IsCategoryNameExistInDb((dtoName as CategoryDTO).CategoryName))
                {
                    resultMessage = BaseDAL.Messages(MessageFor.ItemExistInDatabase, "Category");
                }
                else
                {
                    newCategory.InsertNewCategory((dtoName as CategoryDTO).CategoryName);
                    resultMessage = newCategory.GetCRUDResult();
                }
            }
            else
            {
                //MessageBox.Show("Pone stigna do tuk");
            }
        }
示例#5
0
        internal void Create(BaseDTO dto)
        {
            Task <BaseDTO> t = _client.CreateObjectAsync(dto);

            t.ContinueWith(td =>
            {
                BaseDTO dtoFromServer = td.Result as BaseDTO;
                if (IfErrorShowMessage(dtoFromServer))
                {
                    return;
                }
                if (_dataSources.ContainsKey(dto.GetType()))
                {
                    ICachedData items = _dataSources[dto.GetType()];
                    items.Add(dto);
                }
                else
                {
                    ICachedData cache = new CacheCollection <BaseDTO>();
                    cache.Add(td.Result);
                    _dataSources.Add(dto.GetType(), cache);
                }
            });
        }