Exemple #1
0
        // To protect from overposting attacks, enable the specific properties you want to bind to, for
        // more details, see https://aka.ms/RazorPagesCRUD.
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            _context.Attach(CartItem).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CartItemExists(CartItem.UserId))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(RedirectToPage("./Index"));
        }
Exemple #2
0
        // To protect from overposting attacks, see https://aka.ms/RazorPagesCRUD
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            _context.SupImp.Add(SupImp);
            await _context.SaveChangesAsync();

            return(RedirectToPage("./Index"));
        }
Exemple #3
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            _context.Beer.Add(Beer);
            await _context.SaveChangesAsync();

            UploadedFileName = Image?.FileName;
            using var stream = Image.OpenReadStream();
            UploadedFileLink = await upload.UploadFile(Image.FileName, stream);

            return(RedirectToPage("./Index"));
        }
Exemple #4
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            SupImp = await _context.SupImp.FindAsync(id);

            if (SupImp != null)
            {
                _context.SupImp.Remove(SupImp);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }
        public async Task <IActionResult> OnPostAsync(string id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            CartItem = await _context.CartItems.FindAsync(id);

            if (CartItem != null)
            {
                _context.CartItems.Remove(CartItem);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }
Exemple #6
0
        // To protect from overposting attacks, please enable the specific properties you want to bind to, for
        // more details see https://aka.ms/RazorPagesCRUD.
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            var newRelease = new Release();

            if (await MapInput(newRelease))
            {
                newRelease.CreatedUtc = DateTime.UtcNow;
                _context.Release.Add(newRelease);

                await _context.SaveChangesAsync();

                return(RedirectToPage("./Details", new { Id = newRelease.Id }));
            }

            return(null);
        }
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            _userFromDb = await _userManager.GetUserAsync(User);

            Stakeholder = await _context.Stakeholder
                          .Where(x => x.IdentityUser.Id == _userFromDb.Id)
                          .FirstOrDefaultAsync();

            bool isNew = false;

            if (Stakeholder == null)
            {
                isNew = true;
            }

            var stakeholderToUpdate = isNew ? CreateNewStakeholder() : await _context.Stakeholder
                                      .Where(x => x.IdentityUser.Id == _userFromDb.Id)
                                      .FirstOrDefaultAsync();

            bool mappingSucceeded = await MapInput(stakeholderToUpdate);

            if (mappingSucceeded)
            {
                if (isNew)
                {
                    _context.Stakeholder.Add(stakeholderToUpdate);
                }

                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Details", new { Id = stakeholderToUpdate.Id }));
        }