示例#1
0
        public ActionResult Purchase(PurchaseVM model)
        {
            var purchase = new Purchase();

            purchase.VehicleId = model.VehicleId;
            purchase.Customer  = new Customer()
            {
                Name    = model.Name,
                Email   = model.Email,
                Phone   = model.Phone,
                Street1 = model.Street1,
                Street2 = model.Street2,
                City    = model.City,
                State   = model.State,
                ZipCode = model.Zipcode,
            };
            purchase.PurchaseDate  = DateTime.Now;
            purchase.PurchasePrice = model.PurchasePrice;
            purchase.PurchaseType  = model.PurchaseType;
            purchase.User          = new AppUser()
            {
                UserName = User.Identity.Name,
            };
            _repo.AddPurchase(purchase);

            return(RedirectToAction("Sales"));
        }