public virtual ActionResult SetCustomShipping(long orderId, IList <CustomShippingItemViewModel> items) { LogI("SetCustomShipping, orderId=" + orderId + ", items=" + String.Join(", ", items.Select(i => i.ToString()).ToList())); var rateProviders = ServiceFactory.GetShipmentProviders(LogService, Time, DbFactory, WeightService, AccessManager.Company.ShipmentProviderInfoList, null, null, null, null); var result = CustomShippingItemViewModel.Apply(Db, LogService, Time, WeightService, orderId, rateProviders, CompanyAddress.GetReturnAddress(MarketIdentifier.Empty()), CompanyAddress.GetPickupAddress(MarketIdentifier.Empty()), items, AccessManager.IsFulfilment); if (result.IsSuccess) { return(JsonGet(ValueResult <IList <SelectListShippingOption> > .Success("", result.Data))); } return(JsonGet(ValueResult <IList <SelectListShippingOption> > .Error(result.Message))); }
public virtual ActionResult GetAmazonBarcodeStatus(string barcode) { LogI("GetAmazonBarcodeStatus, barcode=" + barcode); try { var marketplaceManager = new MarketplaceKeeper(DbFactory, false); marketplaceManager.Init(); IMarketApi api = new MarketFactory(marketplaceManager.GetAll(), Time, LogService, DbFactory, null) .GetApi((AccessManager.Company ?? AccessManager.DefaultCompany).Id, MarketType.Amazon, MarketplaceKeeper.AmazonComMarketplaceId); var callResult = ItemEditViewModel.GetAmazonBarcodeStatus(api, barcode); if (callResult.IsSuccess) { return(JsonGet(ValueResult <bool?> .Success("", callResult.Data))); } else { return(JsonGet(ValueResult <bool?> .Error("No results"))); } } catch (Exception ex) { return(JsonGet(ValueResult <bool?> .Error(ex.Message))); } }
public virtual ActionResult GetCloseoutForm() { LogI("GetCloseoutForm"); var marketplaceManager = new MarketplaceKeeper(DbFactory, false); marketplaceManager.Init(); IMarketApi mbgApi = new MarketFactory(marketplaceManager.GetAll(), Time, LogService, DbFactory, null) .GetApi((AccessManager.Company ?? AccessManager.DefaultCompany).Id, MarketType.DropShipper, MarketplaceKeeper.DsToMBG); IMarketApi tmxApi = new MarketFactory(marketplaceManager.GetAll(), Time, LogService, DbFactory, null) .GetApi((AccessManager.Company ?? AccessManager.DefaultCompany).Id, MarketType.DropShipper, MarketplaceKeeper.DsToTMX); var shipmentProvider = ServiceFactory.GetShipmentProviderByType( ShipmentProviderType.IBC, LogService, Time, DbFactory, WeightService, AccessManager.Company.ShipmentProviderInfoList, AppSettings.DefaultCustomType, AppSettings.LabelDirectory, AppSettings.ReserveDirectory, AppSettings.TemplateDirectory); var externalApis = new List <DropShipperApi>(); if (mbgApi != null) { externalApis.Add((DropShipperApi)mbgApi); } if (tmxApi != null) { externalApis.Add((DropShipperApi)tmxApi); } var model = new IbcCloseoutFormViewModel(LogService, Time); var result = model.Closeout(Db, shipmentProvider, externalApis, PdfMaker, AppSettings.LabelDirectory, AppSettings.IsSampleLabels, AccessManager.UserId); if (result.IsSuccess) { return(JsonGet(ValueResult <string> .Success("", result.Data))); } else { return(JsonGet(ValueResult <string> .Error(result.Message))); } }
public virtual ActionResult GetCloseoutForm() { LogI("GetCloseoutForm"); var marketplaceManager = new MarketplaceKeeper(DbFactory, false); marketplaceManager.Init(); IMarketApi mbgApi = new MarketFactory(marketplaceManager.GetAll(), Time, LogService, DbFactory, null) .GetApi((AccessManager.Company ?? AccessManager.DefaultCompany).Id, MarketType.DropShipper, MarketplaceKeeper.DsToMBG); //NOTE: Direct from Marketplaces because TMX is hidden (in active marketplace) IMarketApi tmxApi = new MarketFactory(Db.Marketplaces.GetAllAsDto(), Time, LogService, DbFactory, null) .GetApi((AccessManager.Company ?? AccessManager.DefaultCompany).Id, MarketType.DropShipper, MarketplaceKeeper.DsToTMX); var shipmentProvider = ServiceFactory.GetShipmentProviderByType( ShipmentProviderType.IBC, LogService, Time, DbFactory, WeightService, AccessManager.Company.ShipmentProviderInfoList, AppSettings.DefaultCustomType, AppSettings.LabelDirectory, AppSettings.ReserveDirectory, AppSettings.TemplateDirectory); var model = new IbcCloseoutFormViewModel(LogService, Time); var result = model.Closeout(Db, shipmentProvider, new List <DropShipperApi>() { (DropShipperApi)mbgApi, (DropShipperApi)tmxApi }, PdfMaker, AppSettings.LabelDirectory, AppSettings.IsSampleLabels, AccessManager.UserId); var cacheToRemove = Url.Action("GetInfo", "IbcCloseoutController"); HttpResponse.RemoveOutputCacheItem(path: cacheToRemove); if (result.IsSuccess) { return(JsonGet(ValueResult <string> .Success("", result.Data))); } else { return(JsonGet(ValueResult <string> .Error(result.Message))); } }
public virtual ActionResult ReplaceStyleImage(long id) { LogI("ReplaceStyleImage, itemImageId=" + id); var result = MarketImageViewModel.ReplaceStyleImage(Db, LogService, id, Time.GetAppNowTime(), AccessManager.UserId); if (result.IsSuccess) { return(JsonGet(ValueResult <string> .Success(result.Data))); } return(JsonGet(ValueResult <string> .Error(result.Message))); }
public static ValueResult <long> AddOrdersToBatch(IUnitOfWork db, IOrderHistoryService orderHistoryService, long?batchId, string orderIds, DateTime when, long?by) { if (!string.IsNullOrEmpty(orderIds) && batchId.HasValue) { var batch = db.OrderBatches.GetAsDto(batchId.Value); if (batch.IsClosed) { if (!AccessManager.IsSuperAdmin) { return(ValueResult <long> .Error("Batch was closed", batchId.Value)); } } if (batch.IsLocked) { if (!AccessManager.IsAdmin) { return(ValueResult <long> .Error("Batch was locked", batchId.Value)); } } var stringOrderIdList = orderIds.Split(", ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); var orderIdList = stringOrderIdList.Select(long.Parse).ToList(); db.OrderBatches.AddOrdersToBatch(batchId.Value, orderIdList, when, by); foreach (var orderId in orderIdList) { orderHistoryService.AddRecord(orderId, OrderHistoryHelper.AddToBatchKey, null, null, batchId, batch.Name, by); } return(ValueResult <long> .Success("Batch was created", batchId.Value)); } return(ValueResult <long> .Error("Order list is empty")); }
public virtual ActionResult RequestFeedback(string orderId) { LogI("RequestFeedback, orderId=" + orderId); ValueResult <List <string> > result; try { var by = AccessManager.UserId; var company = AccessManager.Company; var emailService = new EmailService(LogService, SettingsBuilder.GetSmtpSettingsFromCompany(company), AddressService); var sendResult = OrderFeedbackViewModel.SendFeedback(Db, emailService, orderId, Time.GetUtcTime(), by); if (sendResult.Status == CallStatus.Success) { result = ValueResult <List <string> > .Success("Message has been successfully sent", new List <string>() { orderId }); } else { result = ValueResult <List <string> > .Error("Can't send email. Details: " + sendResult.Message); } } catch (Exception ex) { LogE("RequestFeedback", ex); result = ValueResult <List <string> > .Error("Can't send email. Error=" + ex.Message); } return(new JsonResult { Data = result, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); }
public virtual ActionResult GetCloseoutForm() { LogI("GetCloseoutForm"); var shipmentProvider = ServiceFactory.GetShipmentProviderByType( ShipmentProviderType.DhlECom, LogService, Time, DbFactory, WeightService, AccessManager.Company.ShipmentProviderInfoList, AppSettings.DefaultCustomType, AppSettings.LabelDirectory, AppSettings.ReserveDirectory, AppSettings.TemplateDirectory); var model = new DhlCloseoutFormViewModel(LogService, Time); var result = model.Closeout(Db, shipmentProvider, PdfMaker, AppSettings.LabelDirectory, AppSettings.IsSampleLabels, AccessManager.UserId); var cacheToRemove = Url.Action("GetInfo", "DhlCloseoutController"); HttpResponse.RemoveOutputCacheItem(path: cacheToRemove); if (result.IsSuccess) { return(JsonGet(ValueResult <string> .Success("", result.Data))); } else { return(JsonGet(ValueResult <string> .Error(result.Message))); } }
public virtual ActionResult GetPrintResult(int printActionId) { var printAction = Db.SystemActions.GetAllAsDto().FirstOrDefault(a => a.Id == printActionId); if (printAction != null && printAction.Status == (int)SystemActionStatus.Done) { var printOutput = JsonConvert.DeserializeObject <PrintBatchOutput>(printAction.OutputData); var printMessage = String.Join("<br/>- ", printOutput.Messages.Select(m => m.Text).ToList()); LogI("PrintLabelsForBatch, message=" + printMessage); var fileUrl = String.Empty; if (printOutput.PrintPackId.HasValue) { fileUrl = Models.UrlHelper.GetPrintLabelPathById(printOutput.PrintPackId); } var model = new PrintResultViewModel() { Url = fileUrl, NoPdf = String.IsNullOrEmpty(fileUrl), Message = printMessage, PickupReadyByTime = (printOutput.PickupInfo != null && printOutput.PickupInfo.ReadyByTime != null) ? printOutput.PickupInfo.ReadyByTime.Value.ToString("hh\\:mm") : "", PickupConfirmationNumber = printOutput.PickupInfo != null ? printOutput.PickupInfo.ConfirmationNumber : "" }; return(JsonGet(ValueResult <PrintResultViewModel> .Success("", model))); } else { return(JsonGet(ValueResult <SystemActionDTO> .Error("", null))); } }