Ejemplo n.º 1
0
        public ActionResult AddDeliveryAddress([ModelBinder(typeof(CustomerBinderAddNewDeliveryAddress))] CustomerAddDeliveryAddressViewModel cadavm, string[] AddressId, string returnUrl)
        {
            Customer cus = new Customer();
            Address add = new Address();
            CustomerDeliveryAddress cda = new CustomerDeliveryAddress();
            cus = db.Customers.Find(cadavm.deliveryAddress.CustomerId);

            if (AddressId != null)
            {
                if (AddressId.Length > 1)
                {
                    return RedirectToAction("AddDeliveryAddress");
                }

                if (AddressId.Length == 1)
                {
                    add = db.Addresses.Find(Int32.Parse(AddressId.First()));
                    cda.Box = add.Box;
                    cda.CustomerId = cadavm.customer.CustomerId;
                    cda.DeliveryAddressInfo = cadavm.deliveryAddress.DeliveryAddressInfo;
                    cda.PostalCodeNumber = add.PostalCodeNumber;
                    cda.StreetName = add.StreetName;
                    cda.StreetNumber = add.StreetNumber;
                    cda.Town = add.Town;
                    cus.CustomerDeliveryAddress.Add(cda);
                    db.SaveChanges();
                    return Redirect(returnUrl);
                }
            }

            cda = cadavm.deliveryAddress;
            cus.CustomerDeliveryAddress.Add(cda);
            db.SaveChanges();
            return Redirect(returnUrl);
        }
Ejemplo n.º 2
0
        // GET: Orders/Edit/5
        public ActionResult Edit(int? id)
        {
            if (id == null)
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }
            Order order = db.Orders.Find(id);
            var customer = db.Customers.Find(order.CustomerId);
            Address werfadres = new Address();
            werfadres.Box = order.customerDeliveryAddress.Box;
            werfadres.PostalCodeNumber = order.customerDeliveryAddress.PostalCodeNumber;
            werfadres.StreetName = order.customerDeliveryAddress.StreetName;
            werfadres.StreetNumber = order.customerDeliveryAddress.StreetNumber;
            werfadres.Town = order.customerDeliveryAddress.Town;

            OrderEditViewModel oevm = new OrderEditViewModel();
            oevm.order = order;
            oevm.customer = customer;
            oevm.address = werfadres;

            if (order == null)
            {
                return HttpNotFound();
            }
            return View(oevm);
        }
Ejemplo n.º 3
0
        // GET: Quotations/Edit/5
        public ActionResult Edit(int? id)
        {
            if (id == null)
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }
            // opzoeken van de juiste quotation
            Quotation quotation = db.Quotations.Find(id);
            // alle klantgegevens ophalen van de offerte
            var customer = db.Customers.Find(quotation.CustomerId);
            // info opzoeken van het werfadres
            Address werfadres = new Address();
            werfadres.Box = quotation.customerDeliveryAddress.Box;
            werfadres.PostalCodeNumber = quotation.customerDeliveryAddress.PostalCodeNumber;
            werfadres.StreetName = quotation.customerDeliveryAddress.StreetName;
            werfadres.StreetNumber = quotation.customerDeliveryAddress.StreetNumber;
            werfadres.Town = quotation.customerDeliveryAddress.Town;

            // vullen van viewmodel
            QuotationEditViewModel qevm = new QuotationEditViewModel();
            qevm.quotation = quotation;
            qevm.customer = customer;
            qevm.address = werfadres;

            if (quotation == null)
            {
                return HttpNotFound();
            }
            // omgezet naar model
            //ViewBag.CustomerId = new SelectList(db.Customers, "CustomerId", "FullName");
            //var quotDetList = from q in db.QuotationDetails select q;
            //quotDetList = quotDetList.Where(q => q.QuotationId == id);
            //ViewBag.QuotationDetail = quotDetList.ToList();
            return View(qevm);
        }