protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            base.OnModelCreating(modelBuilder);

            BuyerConfiguration.Config(modelBuilder);
            OrderConfiguration.Config(modelBuilder);
        }
        public ResponseModel UpdateOrderConfiguration([FromBody] OrderConfiguration orderConfiguration)
        {
            int           UpdateCount      = 0;
            HSOrderCaller hSOrderCaller    = new HSOrderCaller();
            ResponseModel objResponseModel = new ResponseModel();
            int           statusCode       = 0;
            string        statusMessage    = "";

            try
            {
                string       token        = Convert.ToString(Request.Headers["X-Authorized-Token"]);
                Authenticate authenticate = new Authenticate();
                authenticate = SecurityService.GetAuthenticateDataFromToken(_radisCacheServerAddress, SecurityService.DecryptStringAES(token));

                UpdateCount = hSOrderCaller.UpdateOrderConfiguration(new HSOrderService(_connectionString),
                                                                     orderConfiguration, authenticate.UserMasterID);
                statusCode =
                    UpdateCount.Equals(0) ?
                    (int)EnumMaster.StatusCode.RecordNotFound : (int)EnumMaster.StatusCode.Success;

                statusMessage = CommonFunction.GetEnumDescription((EnumMaster.StatusCode)statusCode);

                objResponseModel.Status       = true;
                objResponseModel.StatusCode   = statusCode;
                objResponseModel.Message      = statusMessage;
                objResponseModel.ResponseData = UpdateCount;
            }
            catch (Exception)
            {
                throw;
            }
            return(objResponseModel);
        }
Esempio n. 3
0
        private void AddOrderConfiguration(ApplicationDbContext context)
        {
            var item = new OrderConfiguration()
            {
                MinBikeQuantity = 24,
                MaxDiscount     = 95
            };

            context.OrderConfigurations.AddOrUpdate(item);
        }
Esempio n. 4
0
        public int UpdateOrderConfiguration(OrderConfiguration orderConfiguration, int modifiedBy)
        {
            int UpdateCount = 0;

            try
            {
                conn.Open();
                MySqlCommand cmd = new MySqlCommand("SP_PHYUpdateOrderConfiguration", conn)
                {
                    Connection = conn
                };
                cmd.Parameters.AddWithValue("@_ID", orderConfiguration.ID);
                cmd.Parameters.AddWithValue("@_IntegratedSystem", Convert.ToInt16(orderConfiguration.IntegratedSystem));
                cmd.Parameters.AddWithValue("@_Payment", Convert.ToInt16(orderConfiguration.Payment));
                cmd.Parameters.AddWithValue("@_Shipment", Convert.ToInt16(orderConfiguration.Shipment));
                cmd.Parameters.AddWithValue("@_ShoppingBag", Convert.ToInt16(orderConfiguration.ShoppingBag));
                cmd.Parameters.AddWithValue("@_StoreDelivery", Convert.ToInt16(orderConfiguration.StoreDelivery));
                cmd.Parameters.AddWithValue("@_AlertCommunicationviaWhtsup", Convert.ToInt16(orderConfiguration.AlertCommunicationviaWhtsup));
                cmd.Parameters.AddWithValue("@_AlertCommunicationviaSMS", Convert.ToInt16(orderConfiguration.AlertCommunicationviaSMS));
                cmd.Parameters.AddWithValue("@_AlertCommunicationviaSMSText", orderConfiguration.AlertCommunicationSMSText);
                cmd.Parameters.AddWithValue("@_EnableClickAfterValue", Convert.ToInt16(orderConfiguration.EnableClickAfterValue));
                cmd.Parameters.AddWithValue("@_EnableClickAfterDuration", orderConfiguration.EnableClickAfterDuration);
                cmd.Parameters.AddWithValue("@_ShoppingBagConvertToOrder", Convert.ToInt16(orderConfiguration.ShoppingBagConvertToOrder));
                cmd.Parameters.AddWithValue("@_ShoppingBagConvertToOrderText", orderConfiguration.ShoppingBagConvertToOrderText);
                cmd.Parameters.AddWithValue("@_AWBAssigned", Convert.ToInt16(orderConfiguration.AWBAssigned));
                cmd.Parameters.AddWithValue("@_AWBAssignedText", orderConfiguration.AWBAssignedText);
                cmd.Parameters.AddWithValue("@_PickupScheduled", Convert.ToInt16(orderConfiguration.PickupScheduled));
                cmd.Parameters.AddWithValue("@_PickupScheduledText", orderConfiguration.PickupScheduledText);
                cmd.Parameters.AddWithValue("@_Shipped", Convert.ToInt16(orderConfiguration.Shipped));
                cmd.Parameters.AddWithValue("@_ShippedText", orderConfiguration.ShippedText);
                cmd.Parameters.AddWithValue("@_Delivered", Convert.ToInt16(orderConfiguration.Delivered));
                cmd.Parameters.AddWithValue("@_DeliveredText", orderConfiguration.DeliveredText);
                cmd.Parameters.AddWithValue("@_ModifiedBy", modifiedBy);

                cmd.CommandType = CommandType.StoredProcedure;
                UpdateCount     = Convert.ToInt32(cmd.ExecuteNonQuery());
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                if (conn != null)
                {
                    conn.Close();
                }
            }

            return(UpdateCount);
        }
Esempio n. 5
0
        public void UpdateOrderConfiguration(Order order, IEnumerable <short> optionIds)
        {
            var optionsToDelete = DataContext.OrderConfigurations.Where(x => x.OrderID == order.ID);

            foreach (var opt in optionsToDelete)
            {
                DataContext.OrderConfigurations.Remove(opt);
            }

            DataContext.SaveChanges();

            foreach (var id in optionIds)
            {
                var opt = new OrderConfiguration {
                    OrderID = order.ID, OptionID = id
                };
                DataContext.OrderConfigurations.Add(opt);
            }

            DataContext.SaveChanges();

            var orderType = DataContext.OrderTypes.SingleOrDefault(x => x.ID == order.TypeID);
            var name      = string.Format("ELCUT {0}", orderType.Name);

            var configurations = DataContext.OrderConfigurations
                                 .Where(x => x.OrderID == order.ID && x.Option.ParentID == null)
                                 .Include(x => x.Option)
                                 .Include(x => x.Option.Options);


            foreach (var opt in configurations)
            {
                name += ", " + opt.Option.Name;
                foreach (var child in opt.Option.Options)
                {
                    name += " +" + child.Name;
                }
                name.Trim(",".ToCharArray());
            }

            order.ConfigurationName = name;

            DataContext.SaveChanges();

            order.Price = order.CalculatePrice();

            DataContext.SaveChanges();
        }
Esempio n. 6
0
        public void CanLoadOrders()
        {
            var order1 = new OrderConfiguration()
            {
                Base       = "BTC",
                Symbol     = "XRP",
                LossStop   = 11m,
                ProfitStop = 8m,
                BuyAmount  = 1m
            };

            var order2 = new OrderConfiguration()
            {
                Base       = "LTC",
                Symbol     = "BTC",
                LossStop   = 15m,
                ProfitStop = 12m,
                BuyAmount  = 2.5m
            };

            var loader = Container.Resolve <IOrdersLoader>();

            Assert.True(loader.Orders.Count == 2);

            var firstOrder  = loader.Orders[0];
            var secondOrder = loader.Orders[1];

            var firstOrdersEqual = order1.Base.Equals(firstOrder.Base) &&
                                   order1.Symbol.Equals(firstOrder.Symbol) &&
                                   order1.ProfitStop.Equals(firstOrder.ProfitStop) &&
                                   order1.LossStop.Equals(firstOrder.LossStop) &&
                                   order1.BuyAmount.Equals(firstOrder.BuyAmount);

            Assert.True(firstOrdersEqual);

            var secondOrdersEqual = order2.Base.Equals(secondOrder.Base) &&
                                    order2.Symbol.Equals(secondOrder.Symbol) &&
                                    order2.ProfitStop.Equals(secondOrder.ProfitStop) &&
                                    order2.LossStop.Equals(secondOrder.LossStop) &&
                                    order2.BuyAmount.Equals(secondOrder.BuyAmount);

            Assert.True(secondOrdersEqual);
        }
Esempio n. 7
0
        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            modelBuilder.HasDefaultSchema("efcore");

            CategoryConfiguration.Configure(modelBuilder.Entity <Category>());
            ShipperConfiguration.Configure(modelBuilder.Entity <Shipper>());
            RegionConfiguration.Configure(modelBuilder.Entity <Region>());
            SupplierConfiguration.Configure(modelBuilder.Entity <Supplier>());
            EmployeeConfiguration.Configure(modelBuilder.Entity <Employee>());
            CustomerDemographicsConfiguration.Configure(modelBuilder.Entity <CustomerDemoGraphic>());
            CustomerConfiguration.Configure(modelBuilder.Entity <Customer>());
            OrderConfiguration.Configure(modelBuilder.Entity <Order>());
            ProductConfiguration.Configure(modelBuilder.Entity <Product>());
            TerritoryConfiguration.Configure(modelBuilder.Entity <Territories>());
            EmployeeTerritoryConfiguration.Configure(modelBuilder.Entity <EmployeeTerritories>());
            CustomerCustomerDemographConfiguration.Configure(modelBuilder.Entity <CustomerCustomerDemograph>());
            OrderDetailConfiguration.Configure(modelBuilder.Entity <OrderDetail>());

            base.OnModelCreating(modelBuilder);
        }
        public OrderCalulationResult CalculateCost(Order order)
        {
            OrderConfiguration orderConfiguration = order.Configuration;
            double             hoursSpent         = CalculateHoursSpent(order);
            double             driversJobCost     = CalculateCostOfDriversJob(hoursSpent, orderConfiguration.DriverJobCostPerHour);
            double             fuelCost           = CalculateFuelCost(order.Distance, orderConfiguration.FuelLiterCost,
                                                                      orderConfiguration.AverageFuelConsumptionPerHundredKilometers);
            double vehicleAmortization = CalculateVehicleAmortization(fuelCost);
            double fullCost            = driversJobCost + fuelCost + vehicleAmortization;

            OrderCalulationResult orderCalulationResult = new OrderCalulationResult
            {
                EndTime             = order.StartTime.AddHours(hoursSpent),
                DriversJobCost      = driversJobCost,
                FuelCost            = fuelCost,
                VehicleAmortization = vehicleAmortization,
                FullCost            = fullCost
            };

            return(orderCalulationResult);
        }
Esempio n. 9
0
        protected override void OnModelCreating(ModelBuilder builder)
        {
            CustomerConfiguration.Configure(builder);
            OrderConfiguration.Configure(builder);

            base.OnModelCreating(builder);

            var entityTypes = builder.Model
                              .GetEntityTypes()
                              .ToList();

            // Set global query filter for not deleted entities only

            // Disable cascade delete
            var foreignKeys = entityTypes
                              .SelectMany(e => e.GetForeignKeys()
                                          .Where(f => f.DeleteBehavior == DeleteBehavior.Cascade));

            foreach (var foreignKey in foreignKeys)
            {
                foreignKey.DeleteBehavior = DeleteBehavior.Restrict;
            }
        }
Esempio n. 10
0
        public OrderConfiguration GetOrderConfiguration(int tenantId, int userId, string programCode)
        {
            DataSet            ds = new DataSet();
            OrderConfiguration moduleConfiguration = new OrderConfiguration();

            try
            {
                conn.Open();
                MySqlCommand cmd = new MySqlCommand("SP_PHYGetOrderConfiguration", conn)
                {
                    CommandType = CommandType.StoredProcedure
                };
                cmd.Parameters.AddWithValue("@_tenantID", tenantId);
                cmd.Parameters.AddWithValue("@_prgramCode", programCode);

                MySqlDataAdapter da = new MySqlDataAdapter
                {
                    SelectCommand = cmd
                };
                da.Fill(ds);

                if (ds != null && ds.Tables[0] != null)
                {
                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        moduleConfiguration.ID = Convert.ToInt32(ds.Tables[0].Rows[0]["ID"]);
                        moduleConfiguration.IntegratedSystem              = ds.Tables[0].Rows[0]["IntegratedSystem"] == DBNull.Value ? false : Convert.ToBoolean(ds.Tables[0].Rows[0]["IntegratedSystem"]);
                        moduleConfiguration.Payment                       = ds.Tables[0].Rows[0]["Payment"] == DBNull.Value ? false : Convert.ToBoolean(ds.Tables[0].Rows[0]["Payment"]);
                        moduleConfiguration.Shipment                      = ds.Tables[0].Rows[0]["Shipment"] == DBNull.Value ? false : Convert.ToBoolean(ds.Tables[0].Rows[0]["Shipment"]);
                        moduleConfiguration.ShoppingBag                   = ds.Tables[0].Rows[0]["ShoppingBag"] == DBNull.Value ? false : Convert.ToBoolean(ds.Tables[0].Rows[0]["ShoppingBag"]);
                        moduleConfiguration.EnableClickAfterValue         = ds.Tables[0].Rows[0]["EnableClickAfterValue"] == DBNull.Value ? 0 : Convert.ToInt16(ds.Tables[0].Rows[0]["EnableClickAfterValue"]);
                        moduleConfiguration.EnableClickAfterDuration      = ds.Tables[0].Rows[0]["EnableClickAfterDuration"] == DBNull.Value ? "" : Convert.ToString(ds.Tables[0].Rows[0]["EnableClickAfterDuration"]);
                        moduleConfiguration.StoreDelivery                 = ds.Tables[0].Rows[0]["StoreDelivery"] == DBNull.Value ? false : Convert.ToBoolean(ds.Tables[0].Rows[0]["StoreDelivery"]);
                        moduleConfiguration.AlertCommunicationviaWhtsup   = ds.Tables[0].Rows[0]["AlertCommunicationviaWhtsup"] == DBNull.Value ? false : Convert.ToBoolean(ds.Tables[0].Rows[0]["AlertCommunicationviaWhtsup"]);
                        moduleConfiguration.AlertCommunicationviaSMS      = ds.Tables[0].Rows[0]["AlertCommunicationviaSMS"] == DBNull.Value ? false : Convert.ToBoolean(ds.Tables[0].Rows[0]["AlertCommunicationviaSMS"]);
                        moduleConfiguration.AlertCommunicationSMSText     = ds.Tables[0].Rows[0]["AlertCommunicationSMSText"] == DBNull.Value ? "" : Convert.ToString(ds.Tables[0].Rows[0]["AlertCommunicationSMSText"]);
                        moduleConfiguration.ShoppingBagConvertToOrder     = ds.Tables[0].Rows[0]["ShoppingBagConvertToOrder"] == DBNull.Value ? false : Convert.ToBoolean(ds.Tables[0].Rows[0]["ShoppingBagConvertToOrder"]);
                        moduleConfiguration.ShoppingBagConvertToOrderText = ds.Tables[0].Rows[0]["ShoppingBagConvertToOrderText"] == DBNull.Value ? "" : Convert.ToString(ds.Tables[0].Rows[0]["ShoppingBagConvertToOrderText"]);
                        moduleConfiguration.AWBAssigned                   = ds.Tables[0].Rows[0]["AWBAssigned"] == DBNull.Value ? false : Convert.ToBoolean(ds.Tables[0].Rows[0]["AWBAssigned"]);
                        moduleConfiguration.AWBAssignedText               = ds.Tables[0].Rows[0]["AWBAssignedText"] == DBNull.Value ? "" : Convert.ToString(ds.Tables[0].Rows[0]["AWBAssignedText"]);
                        moduleConfiguration.PickupScheduled               = ds.Tables[0].Rows[0]["PickupScheduled"] == DBNull.Value ? false : Convert.ToBoolean(ds.Tables[0].Rows[0]["PickupScheduled"]);
                        moduleConfiguration.PickupScheduledText           = ds.Tables[0].Rows[0]["PickupScheduledText"] == DBNull.Value ? "" : Convert.ToString(ds.Tables[0].Rows[0]["PickupScheduledText"]);
                        moduleConfiguration.Shipped                       = ds.Tables[0].Rows[0]["Shipped"] == DBNull.Value ? false : Convert.ToBoolean(ds.Tables[0].Rows[0]["Shipped"]);
                        moduleConfiguration.ShippedText                   = ds.Tables[0].Rows[0]["ShippedText"] == DBNull.Value ? "" : Convert.ToString(ds.Tables[0].Rows[0]["ShippedText"]);
                        moduleConfiguration.Delivered                     = ds.Tables[0].Rows[0]["Delivered"] == DBNull.Value ? false : Convert.ToBoolean(ds.Tables[0].Rows[0]["Delivered"]);
                        moduleConfiguration.DeliveredText                 = ds.Tables[0].Rows[0]["DeliveredText"] == DBNull.Value ? "" : Convert.ToString(ds.Tables[0].Rows[0]["DeliveredText"]);
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                if (conn != null)
                {
                    conn.Close();
                }
                if (ds != null)
                {
                    ds.Dispose();
                }
            }
            return(moduleConfiguration);
        }
Esempio n. 11
0
 public int UpdateOrderConfiguration(IHSOrder order, OrderConfiguration orderConfiguration, int modifiedBy)
 {
     _OrderRepository = order;
     return(_OrderRepository.UpdateOrderConfiguration(orderConfiguration, modifiedBy));
 }
Esempio n. 12
0
 /// <summary>
 /// Restores the meta data.
 /// </summary>
 private static void RestoreMetaData()
 {
     OrderConfiguration.ConfigureMetaData();
 }