示例#1
0
		public void Update(long id, AwbAdminModel model)
		{
			var data = _awbs.Get(id).First();

			AwbMapper.Map(model, data);

			_awbs.Update(id, data);
		}
示例#2
0
        public void Update(long id, AwbAdminModel model)
        {
            var data = _awbRepository.Get(id).First();

            _gtdHelper.ProcessGtd(data, model.GTD);

            _manager.Update(id, model);
        }
示例#3
0
		public void Update(long id, AwbAdminModel model)
		{
			var old = _awbs.Get(id).First();

			AddBrokerEvent(id, old.BrokerId, model.BrokerId);

			_manager.Update(id, model);
		}
示例#4
0
		private static void ReadFiles(HttpRequestBase request, AwbAdminModel model)
		{
			if (model.GTDFile == null && model.GTDFileName == null)
				request.ReadFile("GTDFile", (name, bytes) =>
				{
					model.GTDFileName = name;
					model.GTDFile = bytes;
				});

			if(model.DrawFile == null && model.DrawFileName == null)
				request.ReadFile("DrawFile", (name, bytes) =>
				{
					model.DrawFileName = name;
					model.DrawFile = bytes;
				});

			if (model.GTDAdditionalFile == null && model.GTDAdditionalFileName == null)
				request.ReadFile("GTDAdditionalFile", (name, bytes) =>
				{
					model.GTDAdditionalFileName = name;
					model.GTDAdditionalFile = bytes;
				});

			if (model.PackingFile == null && model.PackingFileName == null)
				request.ReadFile("PackingFile", (name, bytes) =>
				{
					model.PackingFileName = name;
					model.PackingFile = bytes;
				});

			if (model.InvoiceFile == null && model.InvoiceFileName == null)
				request.ReadFile("InvoiceFile", (name, bytes) =>
				{
					model.InvoiceFileName = name;
					model.InvoiceFile = bytes;
				});

			if (model.AWBFile == null && model.AWBFileName == null)
				request.ReadFile("AWBFile", (name, bytes) =>
				{
					model.AWBFileName = name;
					model.AWBFile = bytes;
				});
		}
示例#5
0
文件: AwbMapper.cs 项目: UHgEHEP/test
		public static AirWaybillEditData GetData(AwbAdminModel model)
		{
			return new AirWaybillEditData
			{
				ArrivalAirport = model.ArrivalAirport,
				Bill = model.Bill,
				DepartureAirport = model.DepartureAirport,
				BrokerId = model.BrokerId,
				DateOfArrival = DateTimeOffset.Parse(model.DateOfArrivalLocalString),
				DateOfDeparture = DateTimeOffset.Parse(model.DateOfDepartureLocalString),
				GTD = null,
				AdditionalCost = model.AdditionalCost,
				BrokerCost = model.BrokerCost,
				CustomCost = model.CustomCost,
				FlightCost = model.FlightCost,
				TotalCostOfSenderForWeight = model.TotalCostOfSenderForWeight,
				SenderUserId = model.SenderUserId
			};
		}
示例#6
0
		public virtual ActionResult Edit(long id, AwbAdminModel model)
		{
			try
			{
				if(ModelState.IsValid)
				{
					_awbUpdateManager.Update(id, model);

					return RedirectToAction(MVC.AdminAwb.Edit(id));
				}
			}
			catch(DublicateException)
			{
				ModelState.AddModelError("Bill", Validation.AirWaybillAlreadyExists);
			}

			BindBag(id);

			return View(model);
		}
示例#7
0
		private void Validate(AwbAdminModel expectation, long id)
		{
			using(var connection = new SqlConnection(Settings.Default.MainConnectionString))
			{
				var actual = connection.Query<AwbAdminModel>(
					"select * " +
					"from [dbo].[AirWaybill] where id = @id",
					new { id }).First();

				var actualData = connection.Query<dynamic>(
					"select DateOfDeparture, DateOfArrival " +
					"from [dbo].[AirWaybill] where id = @id",
					new { id }).First();

				actual.DateOfDepartureLocalString = LocalizationHelper.GetDate(actualData.DateOfDeparture, _currentCulture);
				actual.DateOfArrivalLocalString = LocalizationHelper.GetDate(actualData.DateOfArrival, _currentCulture);

				actual.ShouldBeEquivalentTo(expectation);
			}
		}
示例#8
0
		public virtual ActionResult Create(long? applicationId, AwbAdminModel model)
		{
			try
			{
				if(ModelState.IsValid)
				{
					var data = AwbMapper.GetData(model);

					var id = _awbManager.Create(applicationId, data, _identity.Id);

					return RedirectToAction(MVC.AdminAwb.Edit(id));
				}
			}
			catch(DublicateException)
			{
				ModelState.AddModelError("Bill", Validation.AirWaybillAlreadyExists);
			}

			BindBag(null);

			return View(model);
		}
示例#9
0
文件: AwbMapper.cs 项目: UHgEHEP/test
		public static void Map(AwbAdminModel from, AirWaybillEditData to)
		{
			to.ArrivalAirport = from.ArrivalAirport;
			to.Bill = from.Bill;
			to.DepartureAirport = from.DepartureAirport;
			to.GTD = from.GTD;
			to.BrokerId = from.BrokerId;
			to.DateOfArrival = DateTimeOffset.Parse(from.DateOfArrivalLocalString);
			to.DateOfDeparture = DateTimeOffset.Parse(from.DateOfDepartureLocalString);
			to.AdditionalCost = from.AdditionalCost;
			to.BrokerCost = from.BrokerCost;
			to.CustomCost = from.CustomCost;
			to.FlightCost = from.FlightCost;
			to.TotalCostOfSenderForWeight = from.TotalCostOfSenderForWeight;
			to.SenderUserId = from.SenderUserId;
		}