示例#1
0
        public IActionResult OnPost()
        {
            if (ModelState.IsValid)
            {
                var membership = membershipData.GetMebershipById(Customer.MembershipId);
                Customer.Membership = membership;

                if (Customer.Id == 0)
                {
                    Customer            = customerData.Create(Customer);
                    TempData["Message"] = "The Object is created!";
                }
                else
                {
                    Customer            = customerData.Update(Customer);
                    TempData["Message"] = "The Object is updated!";
                }

                customerData.Commit();
                return(RedirectToPage("./List"));
            }

            var memberships = membershipData.GetMemberships().ToList().Select(p => new { Id = p.Id, Display = p.GetMembershipType() });

            Memberships = new SelectList(memberships, "Id", "Display");
            return(Page());
        }