public void TakeOrderInWork(ChangeStatusBindingModel model) { var order = orderLogic.Read(new OrderBindingModel { Id = model.OrderId })?[0]; if (order == null) { throw new Exception("Не найден заказ"); } if (order.Status == OrderStatus.Ожидает_поставки_деталей) { order.Status = OrderStatus.Принят; } if (order.Status != OrderStatus.Принят) { throw new Exception("Заказ не в статусе \"Принят\""); } orderLogic.CreateOrUpdate(new OrderBindingModel { Id = order.Id, ClientId = order.ClientId, Price = order.Price, DateCreate = order.DateCreate, Status = OrderStatus.Выполняется }); }
public ActionResult CreateOrder(CreateOrderModel model) { if (model.Shipping == Shipping.Самовывоз) { model.Address = "Адрес магазина"; } else { ViewBag.Products = _productLogic.Read(null); ModelState.AddModelError("", "Не введён адрес доставки"); return(View(model)); } if (!ModelState.IsValid) { ViewBag.Products = _productLogic.Read(null); return(View(model)); } var orderProducts = new List <OrderProductBindingModel>(); foreach (var product in model.Products) { if (product.Value > 0) { orderProducts.Add(new OrderProductBindingModel { ProductId = product.Key, Count = product.Value }); } } if (orderProducts.Count == 0) { ViewBag.Products = _productLogic.Read(null); ModelState.AddModelError("", "Ни один товар не выбран"); return(View(model)); } _orderLogic.CreateOrUpdate(new OrderBindingModel { ClientId = Program.Client.Id, Date = DateTime.Now, Status = OrderStatus.Принят, Shipping = model.Shipping, Address = model.Address, Sum = CalculateSum(orderProducts), Products = orderProducts }); return(RedirectToAction("Index")); }
public void CreateOrder(CreateOrderBindingModel model) { orderLogic.CreateOrUpdate(new OrderBindingModel { BouquetId = model.BouquetId, ClientId = model.ClientId, Delivery = model.Delivery, Count = model.Count, Sum = model.Sum, DateCreate = DateTime.Now, Status = OrderStatus.Принят }); }
public ActionResult CreateOrder(CreateOrderModel model) { if (!ModelState.IsValid) { var errors = ModelState.Where(x => x.Value.Errors.Any()) .Select(x => new { x.Key, x.Value.Errors }); ViewBag.OrderServices = _serviceLogic.Read(null); return(View(model)); } if (model.OrderServices == null) { ViewBag.OrderServices = _serviceLogic.Read(null); ModelState.AddModelError("", "Услуги не выбраны"); return(View(model)); } var orderServices = new List <OrderServiceBindingModel>(); foreach (var service in model.OrderServices) { if (service.Value == "on") { orderServices.Add(new OrderServiceBindingModel { ServiceId = service.Key, Count = service.Value == "on" ? 1 : 0 }); } } if (orderServices.Count == 0) { ViewBag.Products = _serviceLogic.Read(null); ModelState.AddModelError("", "Услуги не выбраны"); return(View(model)); } _orderLogic.CreateOrUpdate(new OrderBindingModel { ClientId = Program.Client.Id, DateCreate = DateTime.Now, Status = OrderStatus.Принят, Price = CalculateSum(orderServices), OrderServices = orderServices }); return(RedirectToAction("Order")); }
public ActionResult CreateOrder(CreateOrderModel model) { if (!ModelState.IsValid) { ViewBag.Positions = _furnitureModelLogic.Read(null); return(View(model)); } if (model.Positions == null) { ViewBag.Positions = _furnitureModelLogic.Read(null); ModelState.AddModelError("", "Мебель не выбрана"); return(View(model)); } var positions = new List <PositionBindingModel>(); foreach (var furnitureModel in model.Positions) { if (furnitureModel.Value > 0) { positions.Add(new PositionBindingModel { FurnitureModelId = furnitureModel.Key, Count = furnitureModel.Value }); } } if (positions.Count == 0) { ViewBag.Positions = _furnitureModelLogic.Read(null); ModelState.AddModelError("", "Мебель не выбрана"); return(View(model)); } _orderLogic.CreateOrUpdate(new OrderBindingModel { ClientId = Program.Client.Id, OrderDate = DateTime.Now, Status = PaymentStatus.Оформлен, TotalSum = CalculateSum(positions), Positions = positions }); return(RedirectToAction("Order")); }
public void CreateOrder(CreateOrderBindingModel model) { orderLogic.CreateOrUpdate(new OrderBindingModel { KomlectId = model.KomlectId, ClientId = model.ClientId, Count = model.Count, Sum = model.Sum, DateCreate = DateTime.Now, Status = OrderStatus.Принят }); MailLogic.MailSendAsync(new MailSendInfo { MailAddress = clientLogic.Read(new ClientBindingModel { Id = model.ClientId })?[0]?.Email, Subject = $"Новый заказ", Text = $"Заказ принят." }); }
public ActionResult Order(OrderModel model) { ExcursionViewModel excursion = edLogic.Read(new ExcursionBindingModel { Id = model.ExcursionId }).FirstOrDefault(); decimal Remain = CalculateRemain(excursion); if (!ModelState.IsValid) { ViewBag.Excursion = excursion; ViewBag.Remain = Remain; return(View(model)); } if (Remain < model.OrderSum) { ViewBag.Excursion = excursion; ViewBag.Remain = Remain; return(View(model)); } payLogic.CreateOrUpdate(new OrderBindingModel { ExcursionId = excursion.Id, ClientId = Program.Client.Id, DateCreate = DateTime.Now, Sum = model.OrderSum }); Remain -= model.OrderSum; edLogic.CreateOrUpdate(new ExcursionBindingModel { Id = excursion.Id, ClientId = excursion.ClientId, ExcursionCreate = excursion.ExcursionCreate, Status = Remain > 0 ? ExcursionStatus.В_Рассрочке : ExcursionStatus.Заказ_оплачен, Final_Cost = excursion.Cost, RouteForExcursions = excursion.RouteForExcursions.Select(rec => new RouteForExcursionBindingModel { Id = rec.Id, ExcursionId = rec.ExcursionId, RouteId = rec.RouteId, Cost = rec.Cost }).ToList() }); return(RedirectToAction("Excursion")); }
public ViewResult Order(OrderModel model, int BouquetId) { BouquetViewModel product = Blogic.Read(new BouquetBindingModel { Id = BouquetId })?[0]; ViewBag.BouquetName = product.BouquetName; ViewBag.Price = product.Price * model.Count; logic.CreateOrUpdate(new OrderBindingModel { ClientId = Program.Client.Id, BouquetId = BouquetId, Count = model.Count, Delivery = model.DeliveryType, Sum = product.Price * model.Count, DateCreate = DateTime.Now, Status = OrderStatus.Принят }); ModelState.AddModelError("", "Заказ оформлен"); return(View("Order", model)); }
public ActionResult CreateOrder(CreateOrderModel model) { if (!ModelState.IsValid) { ViewBag.OrderCars = _carLogic.Read(null); return(View(model)); } if (model.OrderCars == null) { ViewBag.OrderCars = _carLogic.Read(null); ModelState.AddModelError("", "Выберите автомобиль"); return(View(model)); } var orderCars = new List <OrderCarBindingModel>(); int flag = 0; foreach (var car in model.OrderCars) { if (car.Value > 0) { var cart = _carLogic.Read(new CarBindingModel { Id = car.Key }).FirstOrDefault(); foreach (var det in cart.CarSpares) { var detcount = _SpareLogic.Read(new SpareBindingModel { Id = det.Key }).FirstOrDefault(); if ((det.Value.Item2 * car.Value) > detcount.TotalAmount) { //вывести пользователю ModelState.AddModelError("", "МАЛО ДЕТАЛЕЙ"); flag = 1; int raznica = (det.Value.Item2 * car.Value) - detcount.TotalAmount; } else { _SpareLogic.CreateOrUpdate(new SpareBindingModel { Id = detcount.Id, SpareName = detcount.SpareName, Price = detcount.Price, TotalAmount = detcount.TotalAmount - (det.Value.Item2 * car.Value) }); } } orderCars.Add(new OrderCarBindingModel { CarId = car.Key, Count = car.Value }); } } if (flag == 1) { _orderLogic.CreateOrUpdate(new OrderBindingModel { ClientId = Program.Client.Id, DateCreate = DateTime.Now, Status = OrderStatus.Ожидает_поставки_запчастей, Price = CalculateSum(orderCars), OrderCars = orderCars }); } else { _orderLogic.CreateOrUpdate(new OrderBindingModel { ClientId = Program.Client.Id, DateCreate = DateTime.Now, Status = OrderStatus.Принят, Price = CalculateSum(orderCars), OrderCars = orderCars }); } return(RedirectToAction("Order")); }