// Donate
        public async Task <IActionResult> Donate()
        {
            var user = HttpContext.User.Claims.FirstOrDefault(c => c.Type == "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier");

            var user_id = user.Value;

            var cart = _context.Cart.Where(c => c.UserId == user_id);

            if (String.IsNullOrEmpty(user_id))
            {
                return(RedirectToAction("Index"));
            }
            else
            {
                foreach (var item in cart)
                {
                    Donation donation = new Donation();
                    donation.Amount    = item.Amount;
                    donation.SpeciesId = item.SpeciesId;
                    donation.UserId    = item.UserId;
                    _context.Add(donation);
                }

                _context.SaveChanges();
            }

            RemoveFromCartByUser(user_id);
            // var donate = _context.Donation.Where(c => c.UserId == user_id);
            return(RedirectToAction("Index"));
            // View(await donate.ToListAsync());
        }
Beispiel #2
0
        public async Task <IActionResult> Create([Bind("Id,Label")] StatusCode statusCode)
        {
            if (ModelState.IsValid)
            {
                _context.Add(statusCode);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(statusCode));
        }
Beispiel #3
0
        public async Task <IActionResult> Create([Bind("Id,ComName,Name,SciName,title")] Species species)
        {
            if (ModelState.IsValid)
            {
                db_context.Add(species);
                await db_context.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(species));
        }