예제 #1
0
        public async Task <ActionResult> Create([Bind(Include = "Id,Name,Description,Population")] Region region)
        {
            if (ModelState.IsValid)
            {
                db.Regions.Add(region);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index", "Regions"));
            }
            return(View(region));
        }
예제 #2
0
        public async Task <ActionResult> Edit([Bind(Include = "Id,Email,UserName,SecondName,DateOfBirth")] Customer customer)
        {
            if (ModelState.IsValid)
            {
                db.Entry(customer).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index", "Home"));
            }
            return(View(customer));
        }
예제 #3
0
        public async Task <ActionResult> CreateToken(string token, Donation donation)
        {
            donation.Token = token;
            WorldPayService service = new WorldPayService();

            if (service.MakePayment(donation))
            {
                donation.Id = new Guid();
                donation.OperationDateTime = DateTime.Now;
                IdentityUser user = await UserManager.FindByNameAsync(User.Identity.Name);

                if (user != null)
                {
                    donation.Person = user;
                }

                db.Donations.Add(donation);
                await db.SaveChangesAsync();

                return(RedirectToAction("SuccessDonate"));
            }

            return(RedirectToAction("Create"));
        }