예제 #1
0
        public async Task <IActionResult> Edit(EditOrderView model)
        {
            Order order = await unitOfWork.Orders.Get(model.Id);

            if (order != null)
            {
                string oldEndPoint = order.EndPointCity + ", " + order.EndPointStreet;

                order.EndPointCity   = model.EndPointCity;
                order.EndPointStreet = model.EndPointStreet;

                unitOfWork.Orders.Update(order);
                await unitOfWork.SaveAsync();

                if (model.SendEmail)
                {
                    EmailSender emailSender = new EmailSender();
                    await emailSender.EndPointChangeSend(order, oldEndPoint);
                }

                return(RedirectToAction("Index"));
            }

            return(View(model));
        }
예제 #2
0
        private void EditOrder()
        {
            var vm = new EditOrderViewModel(new UnitOfWorkFactory(), SelectedOrder);

            vm.Init();
            var window = new EditOrderView(vm);

            if (window.ShowDialog() ?? false)
            {
                CollectionViewSource.GetDefaultView(OrderList).Refresh();
            }
        }
예제 #3
0
        private void NewOrder()
        {
            var order = new Order();
            var vm    = new EditOrderViewModel(new UnitOfWorkFactory(), order);

            vm.Init();
            var window = new EditOrderView(vm);

            if (window.ShowDialog() ?? false)
            {
                OrderList.Add(order);
            }
        }
예제 #4
0
        public async Task <IActionResult> Edit(int id)
        {
            Order order = await unitOfWork.Orders.Get(id);

            EditOrderView model = new EditOrderView
            {
                Id              = order.Id,
                CustomerName    = order.Customer.FirstName,
                CustomerSurname = order.Customer.SecondName,
                CustomerEmail   = order.Customer.Email,
                OrderDate       = order.OrderDate,
                EndPointCity    = order.EndPointCity,
                EndPointStreet  = order.EndPointStreet,
                Status          = order.OrderStatus
            };

            return(View(model));
        }
        public async Task Edit_End_Point_Of_Order()
        {
            // Arrange
            string oldEndPointCity = "Lviv";
            var    order           = new Order()
            {
                Id = 1, EndPointCity = oldEndPointCity
            };
            var model = new EditOrderView()
            {
                EndPointCity = "Kiev", EndPointStreet = "Upa, 45"
            };

            // Act
            context.Orders.Add(order);
            context.SaveChanges();
            model.Id = context.Orders.First().Id;
            await controller.Edit(model);

            // Assert
            Assert.AreEqual(1, context.Orders.Count());
            Assert.AreEqual(model.EndPointCity, context.Orders.Single().EndPointCity);
            Assert.AreNotEqual(model.EndPointCity, oldEndPointCity);
        }