Example #1
0
        public async Task <bool> Update(Warehouse Warehouse)
        {
            WarehouseDAO WarehouseDAO = DataContext.Warehouse.Where(x => x.Id == Warehouse.Id).FirstOrDefault();

            if (WarehouseDAO == null)
            {
                return(false);
            }
            WarehouseDAO.Id             = Warehouse.Id;
            WarehouseDAO.Code           = Warehouse.Code;
            WarehouseDAO.Name           = Warehouse.Name;
            WarehouseDAO.Address        = Warehouse.Address;
            WarehouseDAO.OrganizationId = Warehouse.OrganizationId;
            WarehouseDAO.ProvinceId     = Warehouse.ProvinceId;
            WarehouseDAO.DistrictId     = Warehouse.DistrictId;
            WarehouseDAO.WardId         = Warehouse.WardId;
            WarehouseDAO.StatusId       = Warehouse.StatusId;
            WarehouseDAO.RowId          = Warehouse.RowId;
            WarehouseDAO.UpdatedAt      = StaticParams.DateTimeNow;
            await DataContext.SaveChangesAsync();

            await SaveReference(Warehouse);

            return(true);
        }
Example #2
0
        public IActionResult Put(int sku, [FromBody] Product product)
        {
            if (sku <= 0)
            {
                return(BadRequest("Please inform a Sku!"));
            }

            if (!ProductDAO.Exists(sku))
            {
                return(BadRequest("The Sku is already in use!"));
            }

            WarehouseDAO.Delete(sku);

            foreach (Warehouse w in product.Inventory.Warehouses)
            {
                WarehouseDAO.CreateRecord(w, sku);
            }

            if (ProductDAO.Update(product))
            {
                return(Ok("Successfully updated the  record"));
            }

            return(BadRequest("Error while updating record!"));
        }
Example #3
0
        public IActionResult Get(int sku)
        {
            if (sku <= 0)
            {
                return(BadRequest("Please inform a Sku!"));
            }

            if (!ProductDAO.Exists(sku))
            {
                return(BadRequest("No Sku found!"));
            }

            List <Warehouse> warehouses = WarehouseDAO.Find(sku);

            Inventory inventory = new Inventory
            {
                Warehouses = warehouses
            };

            Product product = new Product
            {
                Sku       = sku,
                Name      = ProductDAO.Find(sku),
                Inventory = inventory
            };

            return(Ok(product));
        }
Example #4
0
        public async Task <bool> BulkMerge(List <Warehouse> Warehouses)
        {
            List <WarehouseDAO> WarehouseDAOs = new List <WarehouseDAO>();

            foreach (Warehouse Warehouse in Warehouses)
            {
                WarehouseDAO WarehouseDAO = new WarehouseDAO();
                WarehouseDAO.Id             = Warehouse.Id;
                WarehouseDAO.Code           = Warehouse.Code;
                WarehouseDAO.Name           = Warehouse.Name;
                WarehouseDAO.Address        = Warehouse.Address;
                WarehouseDAO.OrganizationId = Warehouse.OrganizationId;
                WarehouseDAO.ProvinceId     = Warehouse.ProvinceId;
                WarehouseDAO.DistrictId     = Warehouse.DistrictId;
                WarehouseDAO.WardId         = Warehouse.WardId;
                WarehouseDAO.StatusId       = Warehouse.StatusId;
                WarehouseDAO.RowId          = Warehouse.RowId;
                WarehouseDAO.CreatedAt      = StaticParams.DateTimeNow;
                WarehouseDAO.UpdatedAt      = StaticParams.DateTimeNow;
                WarehouseDAOs.Add(WarehouseDAO);
            }
            await DataContext.BulkMergeAsync(WarehouseDAOs);

            return(true);
        }
Example #5
0
        public async Task <bool> Delete(Warehouse Warehouse)
        {
            WarehouseDAO WarehouseDAO = await DataContext.Warehouse.Where(x => x.Id == Warehouse.Id).FirstOrDefaultAsync();

            DataContext.Warehouse.Remove(WarehouseDAO);
            await DataContext.SaveChangesAsync();

            return(true);
        }
        /// <summary>
        /// 콤보박스를 세팅하는 함수
        /// </summary>
        private void SettingCombo()
        {
            WarehouseDAO warehouseDAO = new WarehouseDAO();

            warehouses = warehouseDAO.GetWarehouses(new Warehouse());
            foreach (var item in warehouses)
            {
                cmb_before.Items.Add(item.Warehouse_name);
            }
        }
Example #7
0
        public IActionResult Delete(int sku)
        {
            if (sku > 0)
            {
                if (ProductDAO.Delete(sku) && WarehouseDAO.Delete(sku))
                {
                    return(Ok("Successfully removed the  record"));
                }
            }

            return(BadRequest());
        }
Example #8
0
        public async Task <bool> Update(Warehouse Warehouse)
        {
            WarehouseDAO WarehouseDAO = DataContext.Warehouse.Where(x => x.Id == Warehouse.Id).FirstOrDefault();

            WarehouseDAO.Id        = Warehouse.Id;
            WarehouseDAO.Name      = Warehouse.Name;
            WarehouseDAO.Phone     = Warehouse.Phone;
            WarehouseDAO.Email     = Warehouse.Email;
            WarehouseDAO.Address   = Warehouse.Address;
            WarehouseDAO.PartnerId = Warehouse.PartnerId;
            await DataContext.SaveChangesAsync();

            return(true);
        }
        public List <TruckDAO> FindByParent(WarehouseDAO parent)
        {
            List <TruckDAO> result;

            if (parent == null)
            {
                return(null);
            }

            _logger.Debug("Searching trucks of parent '" + parent.Code + "'");

            result = _trucks.Where(t => t.Parent.Code == parent.Code).ToList();

            return(result);
        }
Example #10
0
        public IActionResult Post([FromBody] Product product)
        {
            if (ProductDAO.Exists(product.Sku))
            {
                return(BadRequest("The Sku is already in use!"));
            }

            foreach (Warehouse w in product.Inventory.Warehouses)
            {
                WarehouseDAO.CreateRecord(w, product.Sku);
            }

            ProductDAO.CreateRecord(product);

            return(Ok("Successfully inserted the new record"));
        }
        public List <WarehouseDAO> FindByParent(WarehouseDAO parent)
        {
            List <WarehouseDAO> result;

            if (parent == null)
            {
                return(_warehouses.Where(w => w.Parent == null).ToList());
            }
            else
            {
                _logger.Debug(string.Format("Searching for Warehouse with parent '{0}'", parent == null ? "" : parent.Code));

                result = _warehouses.Where(w => (w.Parent != null ? w.Parent.Code == parent.Code : false)).ToList();
            }
            return(result);
        }
Example #12
0
        public async Task <bool> Create(Warehouse Warehouse)
        {
            WarehouseDAO WarehouseDAO = new WarehouseDAO();

            WarehouseDAO.Id        = Warehouse.Id;
            WarehouseDAO.Name      = Warehouse.Name;
            WarehouseDAO.Phone     = Warehouse.Phone;
            WarehouseDAO.Email     = Warehouse.Email;
            WarehouseDAO.Address   = Warehouse.Address;
            WarehouseDAO.PartnerId = Warehouse.PartnerId;

            await DataContext.Warehouse.AddAsync(WarehouseDAO);

            await DataContext.SaveChangesAsync();

            Warehouse.Id = WarehouseDAO.Id;
            return(true);
        }
Example #13
0
        public async Task <bool> Create(Warehouse Warehouse)
        {
            WarehouseDAO WarehouseDAO = new WarehouseDAO();

            WarehouseDAO.Id             = Warehouse.Id;
            WarehouseDAO.Code           = Warehouse.Code;
            WarehouseDAO.Name           = Warehouse.Name;
            WarehouseDAO.Address        = Warehouse.Address;
            WarehouseDAO.OrganizationId = Warehouse.OrganizationId;
            WarehouseDAO.ProvinceId     = Warehouse.ProvinceId;
            WarehouseDAO.DistrictId     = Warehouse.DistrictId;
            WarehouseDAO.WardId         = Warehouse.WardId;
            WarehouseDAO.StatusId       = Warehouse.StatusId;
            WarehouseDAO.RowId          = Warehouse.RowId;
            WarehouseDAO.CreatedAt      = StaticParams.DateTimeNow;
            WarehouseDAO.UpdatedAt      = StaticParams.DateTimeNow;
            DataContext.Warehouse.Add(WarehouseDAO);
            await DataContext.SaveChangesAsync();

            Warehouse.Id = WarehouseDAO.Id;
            await SaveReference(Warehouse);

            return(true);
        }
 public void Delete(WarehouseDAO t)
 {
     _warehouses.Remove(t);
 }
 public void Update(WarehouseDAO t)
 {
     throw new NotImplementedException();
 }
 public void Create(WarehouseDAO t)
 {
     t.Id = _autoinc++;
     _warehouses.Add(t);
 }