Пример #1
0
        public static bool ChangeOrderItemStatus(Guid orderItemId, OrderItemStatus status)
        {
            var result = false;

            try
            {
                var entities = new AycemEntities();

                var orderItem = entities.OrderItem.FirstOrDefault(o => o.OrderItemId == orderItemId);

                if (orderItem != null)
                {
                    orderItem.Status = status.ToInt();
                    result           = entities.SaveChanges() > 0;
                }
            }
            catch (Exception)
            {
                throw;
            }
            return(result);
        }
Пример #2
0
        public static bool CreateMachine(string machineName, int productionCapacity, int productionFail)
        {
            var result = false;

            try
            {
                var entities = new AycemEntities();
                var machine  = new Machines
                {
                    MachineId          = Guid.NewGuid(),
                    MachineName        = machineName,
                    ProductionCapacity = productionCapacity,
                    ProductionFail     = productionFail
                };
                entities.Machines.Add(machine);
                result = entities.SaveChanges() > 0;
            }
            catch (Exception ex)
            {
                throw;
            }
            return(result);
        }
Пример #3
0
        public static bool CreateCompany(string name, string phone)
        {
            var result = false;

            try
            {
                var entities = new AycemEntities();

                var company = new Company
                {
                    CompanyId    = Guid.NewGuid(),
                    CompanyName  = name,
                    CompanyTelNo = phone
                };

                entities.Company.Add(company);
                result = entities.SaveChanges() > 0;
            }
            catch (Exception ex)
            {
                throw;
            }
            return(result);
        }
Пример #4
0
        public static bool CreateProduct(string productName)
        {
            var result = false;

            try
            {
                var entities = new AycemEntities();

                var porduct = new Porduct
                {
                    ProductId   = Guid.NewGuid(),
                    ProductName = productName
                };

                entities.Porduct.Add(porduct);

                result = entities.SaveChanges() > 0;
            }
            catch (Exception ex)
            {
                throw;
            }
            return(result);
        }
Пример #5
0
        public static bool CreateOrder(OrderDTO orderDTO)
        {
            var result = false;

            try
            {
                var entities = new AycemEntities();

                var order = new Order
                {
                    OrderId         = Guid.NewGuid(),
                    OrderQuantity   = 0,
                    OrderExpiryDate = orderDTO.OrderExpiryDate,
                    // ModifierRoleId = orderDTO.ModifierRoleId,
                    CompanyId = orderDTO.CompanyId
                };


                entities.Order.Add(order);
                result = entities.SaveChanges() > 0;

                var newId = order.OrderId;

                if (orderDTO.Items != null)
                {
                    foreach (var item in orderDTO.Items)
                    {
                        var orderItem = new OrderItem
                        {
                            OrderId     = newId,
                            ProductId   = item.ProductId,
                            Quantity    = item.Quantity,
                            ColourId    = item.ColourId,
                            OrderItemId = item.OrderItemId
                        };

                        entities.OrderItem.Add(orderItem);
                    }

                    entities.SaveChanges();
                }


                if (orderDTO.Products != null)
                {
                    foreach (var product in orderDTO.Products)
                    {
                        var porduct = new Porduct
                        {
                            ProductId   = product.ProductId,
                            ProductName = product.ProductName,
                        };
                        entities.Porduct.Add(porduct);
                        entities.SaveChanges();
                    }


                    //if (orderDTO.Companies != null) {
                    //     foreach (var companies in orderDTO.Companies)
                    //     {
                    //         var company = new Company
                    //         {
                    //             CompanyId = companies.CompanyId,
                    //             CompanyName = companies.CompanyName,
                    //             CompanyTelNo = companies.CompanyTelNo
                    //         };
                    //         entities.Company.Add(company);
                    //         entities.SaveChanges();
                    //     }

                    // }
                }
            }
            catch (Exception ex)
            {
                throw;
            }
            return(result);
        }