private Error validateShipmentModel(ShipmentModel model) { var error = isValidNonRequiredString(getFieldValue(model.VoyageNo), 25, "VoyageNo", EvolutionResources.errTextDataRequiredInField); if (!error.IsError) { error = isValidNonRequiredString(getFieldValue(model.ConsolidationName), 52, "ConsolidationName", EvolutionResources.errTextDataRequiredInField); } if (!error.IsError) { error = isValidNonRequiredString(getFieldValue(model.Comments), 255, "Comments", EvolutionResources.errTextDataRequiredInField); } if (!error.IsError) { error = isValidNonRequiredString(getFieldValue(model.ConsignmentNo), 50, "ConsignmentNo", EvolutionResources.errTextDataRequiredInField); } if (!error.IsError) { error = isValidNonRequiredString(getFieldValue(model.SeasonText), 15, "Season", EvolutionResources.errTextDataRequiredInField); } if (!error.IsError) { error = isValidNonRequiredString(getFieldValue(model.ContainerNo), 255, "ContainerNo", EvolutionResources.errTextDataRequiredInField); } return(error); }
public Error InsertOrUpdateShipment(ShipmentModel shipment, UserModel user, string lockGuid) { var error = validateShipmentModel(shipment); if (!error.IsError) { // Check that the lock is still current if (!db.IsLockStillValid(typeof(Shipment).ToString(), shipment.Id, lockGuid)) { error.SetError(EvolutionResources.errRecordChangedByAnotherUser, "VoyageNo"); } else { Shipment temp = null; if (shipment.Id != 0) { temp = db.FindShipment(shipment.Id); } if (temp == null) { temp = new Shipment(); } mapToEntity(shipment, temp); db.InsertOrUpdateShipment(temp); shipment.Id = temp.Id; } } return(error); }
public async Task <IActionResult> SetTrackingNumber(ShipmentModel model) { var shipment = await _shipmentService.GetShipmentById(model.Id); if (shipment == null) { //No shipment found with the specified id return(RedirectToAction("List")); } if (_workContext.CurrentCustomer.IsStaff() && shipment.StoreId != _workContext.CurrentCustomer.StaffStoreId) { return(RedirectToAction("List")); } var order = await _orderService.GetOrderById(shipment.OrderId); if (order == null) { //No order found with the specified id return(RedirectToAction("List")); } //a vendor should have access only to his products if (_workContext.CurrentVendor != null && !_workContext.HasAccessToShipment(order, shipment) && !_workContext.CurrentCustomer.IsStaff()) { return(RedirectToAction("List")); } shipment.TrackingNumber = model.TrackingNumber; await _shipmentService.UpdateShipment(shipment); return(RedirectToAction("ShipmentDetails", new { id = shipment.Id })); }
public async Task <IActionResult> EditGenericAttributes(string id, ShipmentModel model) { var shipment = await _shipmentService.GetShipmentById(id); if (shipment == null) { //No order found with the specified id return(RedirectToAction("List")); } //a vendor does not have access to this functionality if (_workContext.CurrentVendor != null && !_workContext.CurrentCustomer.IsStaff()) { return(RedirectToAction("ShipmentDetails", new { id = shipment.Id })); } if (_workContext.CurrentCustomer.IsStaff() && shipment.StoreId != _workContext.CurrentCustomer.StaffStoreId) { return(RedirectToAction("ShipmentDetails", new { id = shipment.Id })); } if (_workContext.CurrentVendor != null && _workContext.CurrentVendor.Id != shipment.VendorId) { ErrorNotification(_localizationService.GetResource("Admin.Orders.Shipments.VendorAccess")); return(RedirectToAction("ShipmentDetails", new { id = shipment.Id })); } shipment.GenericAttributes = model.GenericAttributes; await _shipmentService.UpdateShipment(shipment); //selected tab await SaveSelectedTabIndex(persistForTheNextRequest : false); return(RedirectToAction("ShipmentDetails", new { id = shipment.Id })); }
public async Task DomesticExceptionTest() { await Assert.ThrowsAsync <NullReferenceException>(() => _royalMail.Domestic(null)); ShipmentModel model = new ShipmentModel(); await Assert.ThrowsAsync <ArgumentNullException>(() => _royalMail.Domestic(model)); model.ShipmentType = "type"; await Assert.ThrowsAsync <ArgumentNullException>(() => _royalMail.Domestic(model)); model.Service = new ServiceModel() { Offering = "test", Type = "type" }; await Assert.ThrowsAsync <ArgumentNullException>(() => _royalMail.Domestic(model)); model.RecipientAddress = new AddressModel() { AddressLine1 = "adres", PostCode = "21500", PostTown = "ilce" }; await Assert.ThrowsAsync <ArgumentNullException>(() => _royalMail.Domestic(model)); model.RecipientContact = new ContactModel() { Email = "*****@*****.**" }; }
public ShipmentContentModel AddPurchaseOrder(CompanyModel company, UserModel user, ShipmentModel shipment, PurchaseOrderHeaderModel poh) { ShipmentContentModel newItem = null; var shipmentContent = FindShipmentContentListModel(company, shipment.Id, 0); if (shipmentContent.Items .Where(sc => sc.PurchaseOrderHeaderId == poh.Id) .Count() == 0) { // Not already on the shipment, so add it Supplier supplier = null; if (poh.SupplierId != null) { supplier = db.FindSupplier(poh.SupplierId.Value); } var content = new ShipmentContentModel { CompanyId = company.Id, ShipmentId = shipment.Id, PurchaseOrderHeaderId = poh.Id, OrderNumber = poh.OrderNumber, // Was PONo CBMEstimate = db.FindPurchaseOrderCBMs(poh.Id), //public double? CBMCharged { set; get; } = 0; SupplierId = poh.SupplierId, SupplierName = (supplier == null ? "" : supplier.Name), //public string ProductBrand { set; get; } = ""; }; InsertOrUpdateShipmentContent(content, user, ""); newItem = content; } return(newItem); }
public async Task DomesticTest() { ShipmentModel model = new ShipmentModel() { ShipmentType = "type", Service = new ServiceModel() { Offering = "test", Type = "type" }, RecipientAddress = new AddressModel() { AddressLine1 = "adres", PostCode = "21500", PostTown = "ilce" }, RecipientContact = new ContactModel() { Email = "*****@*****.**" } }; var data = await _royalMail.Domestic(model); Assert.NotNull(data); Assert.IsType <CreatedShipmentResponseModel>(data); Assert.Equal("201", data.HttpCode); }
public async Task <IActionResult> EditUserFields(string id, ShipmentModel model) { var shipment = await _shipmentService.GetShipmentById(id); if (shipment == null) { //No order found with the specified id return(RedirectToAction("List")); } //a vendor does not have access to this functionality if (_workContext.CurrentVendor != null && !await _groupService.IsStaff(_workContext.CurrentCustomer)) { return(RedirectToAction("ShipmentDetails", new { id = shipment.Id })); } if (await _groupService.IsStaff(_workContext.CurrentCustomer) && shipment.StoreId != _workContext.CurrentCustomer.StaffStoreId) { return(RedirectToAction("ShipmentDetails", new { id = shipment.Id })); } if (_workContext.CurrentVendor != null && _workContext.CurrentVendor.Id != shipment.VendorId) { Error(_translationService.GetResource("Admin.Orders.Shipments.VendorAccess")); return(RedirectToAction("ShipmentDetails", new { id = shipment.Id })); } shipment.UserFields = model.UserFields; await _shipmentService.UpdateShipment(shipment); //selected tab await SaveSelectedTabIndex(); return(RedirectToAction("ShipmentDetails", new { id = shipment.Id })); }
public IActionResult PostShipment([FromBody] ShipmentModel model) { try { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } else if (_shipmentsService.IsInvoiceExisted(model.InvoiceNumber)) { return(BadRequest("Duplicate Invoice")); } //else if(!_shipmentsService.IsShipmentAllowed(model.Lines, out string message)) //{ // return BadRequest(message); //} else { bool res = _shipmentsService.PostShipment(model); if (res) { return(Ok()); } return(BadRequest("Shipment Creation failed.")); } } catch (Exception ex) { throw new AppException(ex); } }
public bool PostShipment(ShipmentModel model) { var shipment = _dbContext.Shipments.Add(new Shipments { SpmtCreateddate = DateTime.UtcNow, SpmtCreatedby = CurrentUserId, SpmtInvoiceno = model.InvoiceNumber?.ToUpper(), SpmtLorryno = model.LorryNumber?.ToUpper(), SpmtIsdeleted = false, SpmtShipmentdate = DateTime.UtcNow, SpmtProrId = model.OrderId }); foreach (var line in model.Lines) { _dbContext.Shipmentlines.Add(new Shipmentlines { SpmlCreatedby=CurrentUserId, SpmlCreateddate=DateTime.UtcNow, SpmlIsdeleted=false, SpmlProlId=line.OrderLineId, SpmlQuantity = line.ShippingQuantity, SpmlSpmtId=shipment.Entity.SpmtId }); } return SaveDbChanges(); }
public void SaveShipment(ShipmentModel model) { tShipment shipmentEntity = model.ShipmentEntity(); dc.tShipments.InsertOnSubmit(shipmentEntity); dc.SubmitChanges(); }
public IActionResult SetShipmentAdminComment(ShipmentModel model) { var shipment = _shipmentService.GetShipmentById(model.Id); if (shipment == null) { //No shipment found with the specified id return(RedirectToAction("List")); } var order = _orderService.GetOrderById(shipment.OrderId); if (order == null) { //No order found with the specified id return(RedirectToAction("List")); } //a vendor should have access only to his products if (_workContext.CurrentVendor != null && !_workContext.HasAccessToShipment(order, shipment)) { return(RedirectToAction("List")); } shipment.AdminComment = model.AdminComment; _shipmentService.UpdateShipment(shipment); return(RedirectToAction("ShipmentDetails", new { id = shipment.Id })); }
public ActionResult SetShipmentAdminComment(ShipmentModel model) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageOrders)) { return(AccessDeniedView()); } var shipment = _shipmentService.GetShipmentById(model.Id); if (shipment == null) { //No shipment found with the specified id return(RedirectToAction("List")); } //a vendor should have access only to his products if (_workContext.CurrentVendor != null && !HasAccessToShipment(shipment)) { return(RedirectToAction("List")); } shipment.AdminComment = model.AdminComment; _shipmentService.UpdateShipment(shipment); return(RedirectToAction("ShipmentDetails", new { id = shipment.Id })); }
public async Task <IActionResult> Index() { ShipmentModel model = new ShipmentModel() { ShipmentType = "type", Service = new ServiceModel() { Offering = "test", Type = "type" }, RecipientAddress = new AddressModel() { AddressLine1 = "adres", PostCode = "21500", PostTown = "ilce" }, RecipientContact = new ContactModel() { Email = "*****@*****.**" }, }; //await _royalMail.Domestic(model); //await _royalMail.DomesticT(model); return(View()); }
private void adjustDates(ShipmentModel model, string tz) { model.Date100Shipped = GetFieldValue(model.Date100Shipped, tz); model.DatePreAlertETA = GetFieldValue(model.DatePreAlertETA, tz); model.DateExpDel = GetFieldValue(model.DateExpDel, tz); model.DateWarehouseAccept = GetFieldValue(model.DateWarehouseAccept, tz); model.DateUnpackSlipRcvd = GetFieldValue(model.DateUnpackSlipRcvd, tz); }
public IActionResult UpdateInventory([FromBody] ShipmentModel shipment) { _logger.LogInformation($"Updating product : {shipment.ProductId} by quantity {shipment.Adjustment}"); var response = _inventoryService.UpdateUnitsAvailable(shipment.ProductId, shipment.Adjustment); return(Ok(response)); }
public AcceptanceDropPointForm() { InitializeComponent(); form = this; Load += FormLoad; CurrentModel = new ShipmentModel(); }
public ActionResult UpdateInventory([FromBody] ShipmentModel shipment) { _logger.LogInformation($"Updating inventory for {shipment.ProductId} - " + $"Adjustment: {shipment.Adjustment}"); var inventory = _inventoryService.UpdateUnitsAvailable(shipment.ProductId, shipment.Adjustment); return(Ok(inventory)); }
void prepareEditModel(EditShipmentViewModel model, ShipmentModel shipment) { PrepareViewModel(model, EvolutionResources.bnrAddEditShipment + " - " + EvolutionResources.lblShipment + ": " + model.Shipment.Id.ToString(), shipment.Id, MakeMenuOptionFlags(0, 0, shipment.Id)); model.ShippingMethodList = LookupService.FindLOVItemsListItemModel(CurrentCompany, LOVName.ShippingMethod); model.CarrierVesselList = LookupService.FindCarrierVesselListItemModel(); model.PortList = LookupService.FindPortsListItemModel(); model.SeasonList = LookupService.FindLOVItemsListItemModel(CurrentCompany, LOVName.Season); }
public ShipmentModel CreateShipment(CompanyModel company, UserModel user) { var model = new ShipmentModel { CompanyId = company.Id }; InsertOrUpdateShipment(model, user, ""); return(model); }
public ImportResuls() { InitializeComponent(); im = new ImportTicketModel(); shipment = new ShipmentModel(); dataGridViewX2.DataSource = im.SelectAllImportTicket(); dateTimeInput1.Value = DateTime.Now; dateTimeInput2.Value = DateTime.Now; dateTimeInput3.Value = DateTime.Now; }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); ShipmentsForm view = new ShipmentsForm(); IModel model = new ShipmentModel(); IController controller = new ShipmentController(view, model); Application.Run(view); }
public async Task <IActionResult> EditDeliveryDate(ShipmentModel model) { var shipment = await _shipmentService.GetShipmentById(model.Id); if (shipment == null) { //No shipment found with the specified id return(RedirectToAction("List")); } if (_workContext.CurrentCustomer.IsStaff() && shipment.StoreId != _workContext.CurrentCustomer.StaffStoreId) { return(RedirectToAction("List")); } if (_workContext.CurrentVendor != null && _workContext.CurrentVendor.Id != shipment.VendorId) { ErrorNotification(_localizationService.GetResource("Admin.Orders.Shipments.VendorAccess")); return(RedirectToAction("ShipmentDetails", new { id = shipment.Id })); } var order = await _orderService.GetOrderById(shipment.OrderId); if (order == null) { //No order found with the specified id return(RedirectToAction("List")); } //a vendor should have access only to his products if (_workContext.CurrentVendor != null && !_workContext.HasAccessToShipment(order, shipment) && !_workContext.CurrentCustomer.IsStaff()) { return(RedirectToAction("List")); } try { if (!model.DeliveryDate.HasValue) { throw new Exception("Enter delivery date"); } shipment.DeliveryDateUtc = model.DeliveryDate.ConvertToUtcTime(_dateTimeHelper); await _shipmentService.UpdateShipment(shipment); return(RedirectToAction("ShipmentDetails", new { id = shipment.Id })); } catch (Exception exc) { //error ErrorNotification(exc, true); return(RedirectToAction("ShipmentDetails", new { id = shipment.Id })); } }
public ActionResult UpdateInventory([FromBody] ShipmentModel shipment) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var id = shipment.ProductId; var adjustment = shipment.Adjustment; var inventory = _inventoryService.UpdateUnitsAvailable(id, adjustment); return(Ok(inventory)); }
public ActionResult UpdateInventory([FromBody] ShipmentModel shipment) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _logger.LogInformation($"Updating inventory for {shipment.ProductId} - Adjustment: {shipment.Adjustment}"); var response = _inventoryService.UpdateUnitsAvailable(shipment.ProductId, shipment.Adjustment); return(Ok(response)); }
public ActionResult UpdateStock([FromBody] ShipmentModel shipment) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var id = shipment.MaterialId; var adjustment = shipment.Adjustment; var stock = _stockService.ModifyAvailableUnits(id, adjustment); return(Ok(stock)); }
public ActionResult UpdateInventory([FromBody] ShipmentModel shipment) { logger.LogInformation( "Updating inventory " + $" for {shipment.ProductId} - " + $" Adjustment {shipment.Adjustment}"); var id = shipment.ProductId; var adjustment = shipment.Adjustment; var inventory = inventoryService.UpdateUnitsAvailable(id, adjustment); return(Ok(inventory)); }
public static tShipment ShipmentEntity(this ShipmentModel item) { return(new tShipment { Id = item.Id, ShipmentDate = item.ShipmentDate, OriginDepotId = item.OriginDepotId, TargetDepotId = item.TargetDepotId, MaterialId = item.MaterialId, Amount = item.Amount }); }
public async Task <BaseResult> CreateOrUpdate(ShipmentModel model) { Shipment shipment = model.ToShipment(); if (shipment.Id > 0) { return(await Update(shipment)); } else { return(await Create(shipment)); } }
public async Task Test_GetShipmentById_Is_Ok() { try { ShipmentModel currentShipmentModel = await _shipmentService.Get(54, 1); } catch (Exception ex) { Assert.IsFalse(true); } Assert.IsTrue(true); }