Beispiel #1
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

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

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ConnectionExists(Connection.ID))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

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

            //check if user exists
            var exists = _context.Clients.Where(c => c.Number == Client.Number && c.Name.ToUpper() == Client.Name.ToUpper() && c.Surname.ToUpper() == Client.Surname.ToUpper());

            if (exists.Count() > 0)
            {
                //client exits
                ModelState.AddModelError("Error", "User already exists");
                ViewData["TitleID"] = new SelectList(_context.Titles, "ID", "Name");
                return(Page());
            }
            else
            {
                _context.Clients.Add(Client);

                await _context.SaveChangesAsync();

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

            _context.Packages.Add(Package);
            await _context.SaveChangesAsync();

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

            Subscription = await _context.Subscriptions.FindAsync(id);

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

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

            Title = await _context.Titles.FindAsync(id);

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

            return(RedirectToPage("./Index"));
        }