Beispiel #1
0
        public static ContactViewModel From(Contact contact)
        {
            ContactViewModel contactViewModel = new ContactViewModel();
            contactViewModel.City = contact.City;
            contactViewModel.Country = contact.Country;
            contactViewModel.House = contact.House;
            contactViewModel.Room = contact.Room;
            contactViewModel.Street = contact.Street;
            contactViewModel.Zip = contact.Zip;
            contactViewModel.Region = contact.Region;

            contactViewModel.Name = contact.Name;
            contactViewModel.Surname = contact.Surname;
            contactViewModel.Phone = contact.Phone;

            return contactViewModel;
        }
Beispiel #2
0
        public ActionResult Edit(ContactViewModel contactViewModel, int uid, DeliverType DeliverType, PaymentType PaymentType)
        {
            if (!ModelState.IsValid || DeliverType == DeliverType.NULL)
            {
                if (DeliverType == DeliverType.NULL)
                {
                    ModelState.AddModelError("DeliverType", "Выберите способ доставки");
                }
                return View(daoTemplate.FindOrderByUid(uid));
            }

            var order = daoTemplate.FindOrderByUid(uid);
            var contact = Contact.From(contactViewModel);
            order.ShippingDetails = contact;
            order.PaymentType = PaymentType;
            order.DeliverType = DeliverType;
            order.DeliverPrice = orderService.GetPrice(order.DeliverType);
            daoTemplate.Save(order);
            return RedirectToAction("DetailsUser", new {id = order.Uid});
        }