public virtual ActionResult GetOrderById(long orderId) { var rowOrderDto = Db.ItemOrderMappings.GetOrderWithItems(WeightService, orderId, false, true, unmaskReferenceStyles: true); //NOTE: Unmask for display var rowModel = new OrderViewModel(rowOrderDto, AccessManager.IsFulfilment); rowModel.Items = rowOrderDto.Items.Select(i => new OrderItemViewModel(i, rowOrderDto.OnHold, ShippingUtils.IsOrderPartial(rowOrderDto.OrderStatus))).ToList(); return(JsonGet(ValueResult <OrderViewModel> .Success("", rowModel))); }
public virtual ActionResult Submit(OrderEditViewModel model) { LogI("Submit, model=" + model); //Save if (ModelState.IsValid) { var company = AccessManager.Company; var serviceFactory = new ServiceFactory(); var addressProviders = AccessManager.Company.AddressProviderInfoList .Where(a => a.Type != (int)AddressProviderType.SelfCorrection) .ToList(); //NOTE: exclude self correction var addressCheckService = serviceFactory.GetAddressCheckServices(LogService, Time, DbFactory, addressProviders); var companyAddress = new CompanyAddressService(company); var addressService = new AddressService(addressCheckService, companyAddress.GetReturnAddress(MarketIdentifier.Empty()), companyAddress.GetPickupAddress(MarketIdentifier.Empty())); var addressChecker = new AddressChecker(LogService, DbFactory, addressService, OrderHistoryService, Time); //var validatorService = new OrderValidatorService(LogService, // DbFactory, // EmailService, // OrderHistoryService, // ActionService, // HtmlScraper, // addressService, // null, // null, // Time, // AccessManager.Company); var rateProviders = ServiceFactory.GetShipmentProviders(LogService, Time, DbFactory, WeightService, AccessManager.Company.ShipmentProviderInfoList, null, null, null, null); var syncInfo = new EmptySyncInformer(LogService, SyncType.Orders); var synchronizer = new AmazonOrdersSynchronizer(LogService, AccessManager.Company, syncInfo, rateProviders, CompanyAddress, Time, WeightService, MessageService); var applyResult = model.Apply(LogService, Db, OrderHistoryService, QuantityManager, Time.GetAppNowTime(), AccessManager.UserId); var resultErrors = model.ProcessApplyResult(applyResult, Db, LogService, Time, synchronizer, addressChecker, OrderHistoryService, WeightService, AccessManager.UserId); if (resultErrors.Any()) { resultErrors.ForEach(r => ModelState.AddModelError(r.Key, r.Message)); return(PartialView("OrderEdit", model)); } var rowOrderDto = Db.ItemOrderMappings.GetOrderWithItems(WeightService, model.EntityId, false, true, unmaskReferenceStyles: true); //NOTE: Unmask for display var rowModel = new OrderViewModel(rowOrderDto, AccessManager.IsFulfilment); rowModel.Items = rowOrderDto.Items.Select(i => new OrderItemViewModel(i, rowOrderDto.OnHold, ShippingUtils.IsOrderPartial(rowOrderDto.OrderStatus))).ToList(); return(Json(new UpdateRowViewModel(rowModel, model.BatchId.HasValue ? "grid_" + model.BatchId.Value : "grid", null, false))); } return(PartialView("OrderEdit", model)); }