コード例 #1
0
        protected ActionResult DisplayDetails(OrderDetailDTO item)
        {
            var vm = GetViewModelFromTempData<OrderDetailViewModel>();
            if (vm == null) { return RedirectToReferrer(); }

            vm.DisplayName = Strings.OrderDetailDetailView_Title;
            vm.SelectedItem = item;
            vm.Products = vm.Products ?? Service.GetAllProducts().ToList();

            // Finish Action
            StoreViewModelToTempData(vm);
            TempData.Keep();
            return View(vm);
        }
コード例 #2
0
        public void TestOrderDetailModel()
        {
            OrderDetailDTO detailDto = new OrderDetailDTO() {Id = 1, QuantityInUnits = 123, UnitPrice = 213, ProductId = 1, ProductName = "FAkeProduct", Version = 1};
            OrderDTO dto = new OrderDTO() {Id = 1, OrderStatus = OrderStatus.Ordered, OrderDate = DateTime.Now, ShippedDate = null, CustomerId = 123, CustomerName = "Fakecustomer"};
            dto.Details.Add(detailDto);

            OrderDetailViewModel orderDetailViewModel = new OrderDetailViewModel(dto, false);
            orderDetailViewModel.Service = serviceFacade;

            Expect.Once.On(serviceFacade).Method("StoreOrder").With(dto);
            orderDetailViewModel.SaveCommand.Command.Execute(null);

            Assert.AreEqual(dto, orderDetailViewModel.Model);
            Assert.AreEqual(Strings.OrderDetailViewModel_DisplayName, orderDetailViewModel.DisplayName);

            OrderItemViewModel detailListViewModel = (OrderItemViewModel) orderDetailViewModel.ListViewModel;
            Assert.AreEqual(detailDto, detailListViewModel.Items.FirstOrDefault());
        }
コード例 #3
0
 public void TestOrderDetailViewModel()
 {
     OrderDetailDTO dto = new OrderDetailDTO() {Id = 1, QuantityInUnits = 123, UnitPrice = 213, ProductId = 1, ProductName = "FAkeProduct", Version = 1};
     OrderItemDetailViewModel viewModel = new OrderItemDetailViewModel(dto, false);
     Assert.AreEqual(dto, viewModel.Model);
     Assert.AreEqual(Strings.OrderItemDetailViewModel_DisplayName, viewModel.DisplayName);
 }
コード例 #4
0
 // GET: OrderDetail/Create
 public ActionResult Create()
 {
     OrderDetailDTO item = new OrderDetailDTO();
     return DisplayDetails(item);
 }
コード例 #5
0
        public void TestDtoToOrder()
        {
            OrderDetailDTO detailDto = new OrderDetailDTO() { Id = 1, QuantityInUnits = 123, UnitPrice = 213, ProductId = 1, ProductName = "FAkeProduct", Version = 1 };
            OrderDTO dto = new OrderDTO() { Id = 1, OrderStatus = OrderStatus.Ordered, OrderDate = DateTime.Now, ShippedDate = null, CustomerId = 123, CustomerName = "Fakecustomer" };
            dto.Details.Add(detailDto);
            Assert.AreEqual(true, dto.IsValid);
            Assert.AreEqual(true, detailDto.IsValid);

            Order order = OrderAdapter.DtoToOrder(dto);
            Assert.AreEqual<int>(dto.Id, order.OrderId);
            Assert.AreEqual<int>((int) dto.OrderStatus, (int) order.OrderStatus);
            Assert.AreEqual<DateTime?>(dto.OrderDate, order.OrderDate);
            Assert.AreEqual<DateTime?>(dto.ShippedDate, order.ShippedDate);
            Assert.AreEqual<int>(dto.CustomerId, order.Customer.CustomerId);
            //TODO: Assert.AreEqual<string>(dto.CustomerName, order.Customer.Username);
            Assert.AreEqual(dto.Version, order.Version);

            //TODO: Assert.AreEqual<int>(dto.Details.Count(), order.Details.Count());
            Assert.AreEqual(true, order.IsValid);
        }
コード例 #6
0
ファイル: OrderAdapter.cs プロジェクト: ikelos555/HSROrderApp
 private static OrderDetail DtoToDetail(OrderDetailDTO dto, Order order)
 {
     OrderDetail detail = new OrderDetail()
                              {
                                  OrderDetailId = dto.Id,
                                  QuantityInUnits = dto.QuantityInUnits,
                                  UnitPrice = dto.UnitPrice,
                                  Product = new Product() {ProductId = dto.ProductId},
                                  Version = dto.Version
                              };
     detail.Order = order;
     ValidationHelper.Validate(detail);
     return detail;
 }