// GET: DiscDesign/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            DiscDesignModel discDesignModel = db.DiscDesignModels.Find(id);

            if (discDesignModel == null)
            {
                return(HttpNotFound());
            }
            DiscDesignViewModel dvm = new DiscDesignViewModel
            {
                Id          = discDesignModel.Id,
                VehicleName = discDesignModel.VehicleName,
                TaxDay      = discDesignModel.TaxDateTime.Day,
                TaxMonth    = discDesignModel.TaxDateTime.Month,
                TaxYear     = discDesignModel.TaxDateTime.Year,
                MotDay      = discDesignModel.MotDateTime.Day,
                MotMonth    = discDesignModel.MotDateTime.Month,
                MotYear     = discDesignModel.MotDateTime.Year
            };

            return(View(dvm));
        }
예제 #2
0
        public ActionResult DiscDesign(DiscDesignViewModel discDesignView)
        {
            var discDesign = new DiscDesignModel()
            {
                VehicleName = db.Users.Single(u => u.Id == discDesignView.VehicleName),
                TaxDateTime = DateTime.Parse(string.Format("{0} {1} {2} ", discDesignView.TaxDay, discDesignView.TaxMonth, discDesignView.TaxYear)),
                MotDateTime = DateTime.Parse(string.Format("{0} {1} {2} ", discDesignView.MotDay, discDesignView.MotMonth, discDesignView.MotYear))
            };

            db.DiscDesignModels.Add(discDesign);
            db.SaveChanges();

            return(RedirectToAction("ThankYou", "Home"));
        }
        public ActionResult Edit(DiscDesignViewModel discDesignView)
        {
            if (ModelState.IsValid)
            {
                var discDesignModel = new DiscDesignModel()
                {
                    Id          = discDesignView.Id,
                    VehicleName = discDesignView.VehicleName,
                    TaxDateTime = DateTime.Parse(string.Format("{0} {1} {2} ", discDesignView.TaxDay, discDesignView.TaxMonth, discDesignView.TaxYear)),
                    MotDateTime = DateTime.Parse(string.Format("{0} {1} {2} ", discDesignView.MotDay, discDesignView.MotMonth, discDesignView.MotYear))
                };

                db.Entry(discDesignModel).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(View(discDesignView));
        }