private int GetUrgentStatus(Core.Models.Order order) { var deliveryDate = order.DeliveryDate; if (!deliveryDate.HasValue || order.OrderStatus == OrderStatus.Delete || order.OrderStatus == OrderStatus.Shipment || order.OrderStatus == OrderStatus.HaveGoods) { return((int)UrgentStatus.Normal); } var now = DateTime.Now.Date; var intervalDate = (deliveryDate.Value - now).TotalDays; if (intervalDate > SaleManagentConstants.UI.OrderUrgentWaringDay) { return((int)UrgentStatus.Normal); } if (intervalDate <= SaleManagentConstants.UI.OrderUrgentWaringDay && intervalDate > SaleManagentConstants.UI.OrderVeryUrgentWaringDay) { return((int)UrgentStatus.Urgent); } if (intervalDate <= SaleManagentConstants.UI.OrderVeryUrgentWaringDay) { return((int)UrgentStatus.VeryUrgent); } return((int)UrgentStatus.Normal); }
public ShipmentOrderInfoViewModel(Core.Models.Order order) : base(order) { OutputWaxCost = order.OutputWaxCost; ProductName = order.ColorForm.Name + order.GemCategory.Name + order.ProductCategory.Name; Weight = order.Weight; GoldWeight = order.GoldWeight; OrderSetStoneInfos = order.OrderSetStoneInfos != null?order.OrderSetStoneInfos.Select(o => new OrderSetStoneInfoViewModel { MatchStoneId = o.MatchStoneId, MatchStoneName = o.MathchStoneName, Number = o.Number, Weight = o.Weight, Price = o.Price, TotalAmount = o.Price * (double)o.Weight, SetStoneWorkingCost = o.WorkingCost }) : new List <OrderSetStoneInfoViewModel>(); OrderMainStoneInfos = order.OrderMainStoneInfos != null?order.OrderMainStoneInfos.Select(o => new OrderMainStoneInfoViewModel { Id = o.Id, MainStoneName = o.MainStone.Name, RiskType = o.MainStone.RiskType, Weight = o.Weight, Created = o.Created.ToString(SaleManagentConstants.UI.DateStringFormat) }) : new List <OrderMainStoneInfoViewModel>(); }
public OrderSetMainStoneViewModel(Core.Models.Order order) : base(order) { OrderMainStoneInfos = order.OrderMainStoneInfos.Select(o => new OrderMainStoneInfoViewModel { Id = o.Id, MainStoneName = o.MainStone.Name, RiskType = o.MainStone.RiskType, Weight = o.Weight, Created = o.Created.ToString(SaleManagentConstants.UI.DateStringFormat) }); }
public OrderSetStoneViewModel(Core.Models.Order order) : base(order) { OrderSetStoneInfos = order.OrderSetStoneInfos.Select(o => new OrderSetStoneInfoViewModel { Id = o.Id, MatchStoneId = o.MatchStoneId, MatchStoneName = o.MathchStoneName, Number = o.Number, Weight = o.Weight }); }
public ActionResult <Core.Models.Order> Post([FromBody] Core.Models.Order order) { if (order.OrderId == 0) { orderRepository.InsertOrder(order); } else { orderRepository.UpdateOrder(order); } return(order); }
public void InsertOrder(Core.Models.Order order) { const string initialSeedSQL = "INSERT INTO CustomerOrder(CustomerId, TotalPrice, OrderDate) VALUES(@customerid, @totalprice, @orderdate)"; using (var connection = new SqliteConnection(connectionString)) using (var command = new SqliteCommand(initialSeedSQL, connection)) { command.Parameters.AddWithValue("@customerid", order.CustomerId); command.Parameters.AddWithValue("@totalprice", order.TotalPrice); command.Parameters.AddWithValue("@orderdate", order.OrderDate); connection.Open(); command.ExecuteNonQuery(); connection.Close(); } }
public void UpdateOrder(Core.Models.Order order) { const string initialSeedSQL = "UPDATE CustomerOrder SET CustomerId = @customerid, TotalPrice = @totalprice, OrderDate = @orderdate WHERE OrderId = @orderid"; using (var connection = new SqliteConnection(connectionString)) using (var command = new SqliteCommand(initialSeedSQL, connection)) { command.Parameters.AddWithValue("@customerid", order.CustomerId); command.Parameters.AddWithValue("@totalprice", order.TotalPrice); command.Parameters.AddWithValue("@orderdate", order.OrderDate); command.Parameters.AddWithValue("@orderid", order.OrderId); connection.Open(); command.ExecuteNonQuery(); connection.Close(); } }
public static Order ToProto(this Core.Models.Order order) { var proto = new Order { Id = order.Id, UserId = order.UserId, Date = order.Date.ToString("O") }; if (order.Items != null) { var itemProtos = order.Items?.Select(x => x.ToProto()); proto.Items.Add(itemProtos); } return(proto); }
public static Core.Models.Order ToEntity(this Order order) { var entity = new Core.Models.Order { Id = order.Id, UserId = order.UserId, Date = DateTime.Parse(order.Date) }; if (order.Items != null) { entity.Items = order.Items.Select(x => x.ToEntity()).ToList(); } return(entity); }
private double GetOrderRushCost(Core.Models.Order order) { if (order.OrderRushStatus == Core.Models.OrderRushStatus.Normal) { return(0); } var now = DateTime.Now; if (order.OrderRushStatus == Core.Models.OrderRushStatus.VeryRush && now < order.DeliveryDate) { return(300); } if (now < order.Created.AddDays(8)) { return(100); } return(0); }
public OrderViewModelBase(Core.Models.Order order) { Id = order.Id; MainStoneSize = order.MainStoneSize; MainStoneNumber = order.MainStoneNumber; Number = order.Number; Certificate = order.Certificate; RabbetRequirement = order.RabbetRequirement; StoneDescribe = order.StoneDescribe; GoldWeightRequirement = order.GoldWeightRequirement; SideStoneRequiredment = order.SideStoneRequiredment; RadianRequirement = order.RadianRequirement; HasOldMaterial = order.HasOldMaterial; RangSize = GetRang(order); WordsPrinted = order.WordsPrinted; Remark = order.Remark; ProductCategoryId = order.ProductCategoryId; ColorFormId = order.ColorFormId; GemCategoryId = order.GemCategoryId; CustomerId = order.CustomerId; HandSize = order.HandSize; MinChainLength = order.MinChainLength; MaxChainLength = order.MaxChainLength; DeliveryDate = order.DeliveryDate?.ToString(SaleManagentConstants.UI.DateStringFormat) ?? ""; CustomerName = order.Customer.Name; Created = order.Created.ToString(SaleManagentConstants.UI.DateStringFormat); ColorFormName = order.ColorForm?.Name; GemCategoryName = order.GemCategory?.Name; ProductCategoryName = order.ProductCategory?.Name; OutputWaxCost = order.OutputWaxCost; ModuleTypeName = order.ModuleType.GetDisplayName(); OrderRushStatus = order.OrderRushStatus; IsInsure = order.IsInsure; Insurance = order.Insurance; DesginCost = order.DesginCost; }
public Core.Models.Order Post([FromBody] Core.Models.Order order) { return(caller.PostAsync <Core.Models.Order>(configuration["ApiUrls:Order"], order).Result); }
//[Authorize(Roles = RoleName.AskAdmin + "," + RoleName.AskUser)] public void PlaceOrder() { var basketItems = basketService.GetBasketItems(this.HttpContext); var order = new Core.Models.Order { OrderNumber = Common.GetRandomInvoiceNumber() }; OrderItem orderitems = new OrderItem(); foreach (var item in basketItems) { orderitems.OrderId = order.Id; orderitems.ProductId = item.ProductId; orderitems.ProductName = item.ProductName; orderitems.Image = item.Image; orderitems.Image2 = item.Image2; orderItemContext.Commit(); } order.InvoiceNumber = "Shop.MyRockies.Network" + @DateTime.Now.Year + order.OrderNumber; order.OrderStatus = "Order Created"; orderService.CreateOrder(order, basketItems); order.OrderStatus = "Payment Processed"; //order.CompletedAt = DateTime.Now; orderService.UpdateOrder(order); //Make the product sold remove foreach (var item in order.OrderItems) { List <Product> products = productContext.Collection().Where(p => p.Id == item.ProductId).ToList(); foreach (var prod in products) { Product product = productContext.Find(prod.Id); product.Sold = true; product.DateSold = DateTime.Now; productContext.Commit(); } } //Email Customer string CustomerEmail = User.Identity.Name;; var subject = "Shop.MyRockies.Network New Order: " + order.OrderNumber + " Recieved"; var fromAddress = "*****@*****.**"; var toAddress = CustomerEmail; var emailBody = "Email From: Shop.MyRockies.Network Message: Thank you for your order: " + order.OrderNumber; var smtp = new SmtpClient(); { smtp.Host = "smtp.myrockies.network"; smtp.Port = 587; smtp.EnableSsl = false; smtp.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network; smtp.Credentials = new NetworkCredential("*****@*****.**", "bdFawHs7"); smtp.Timeout = 20000; } smtp.Send(fromAddress, toAddress, subject, emailBody); //Email Admin subject = "Store.com New Question: " + order.OrderNumber; fromAddress = "*****@*****.**"; toAddress = "*****@*****.**"; emailBody = "Email From: Store.com Message: A New Order: " + order.OrderNumber; var smtp1 = new SmtpClient(); { smtp1.Host = "smtp.myrockies.network"; smtp1.Port = 587; smtp1.EnableSsl = false; smtp1.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network; smtp1.Credentials = new NetworkCredential("*****@*****.**", "bdFawHs7"); smtp1.Timeout = 20000; } smtp1.Send(fromAddress, toAddress, subject, emailBody); basketService.ClearBasket(this.HttpContext); }