Exemplo n.º 1
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());
            }

            //_db.Attach(ServiceType).State = EntityState.Modified;

            var serviceFromDb = await _db.ServiceType.FirstOrDefaultAsync(s => s.Id == ServiceType.Id);

            serviceFromDb.Name  = ServiceType.Name;
            serviceFromDb.Price = ServiceType.Price;

            await _db.SaveChangesAsync();

            /* this is used for default settings
             * try
             * {
             *  await _db.SaveChangesAsync();
             * }
             * catch (DbUpdateConcurrencyException)
             * {
             *  if (!ServiceTypeExists(ServiceType.Id))
             *  {
             *      return NotFound();
             *  }
             *  else
             *  {
             *      throw;
             *  }
             * }
             */
            return(RedirectToPage("./Index"));
        }
Exemplo n.º 2
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());
            }

            _db.Attach(ServiceType).State = EntityState.Modified;

            try
            {
                await _db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ServiceTypeExists(ServiceType.Id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

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

            _db.ServiceType.Add(ServiceType);
            await _db.SaveChangesAsync();

            return(RedirectToPage("./Index"));
        }
Exemplo n.º 4
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

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

            await _context.SaveChangesAsync();

            return(RedirectToPage("./Index"));
        }
Exemplo n.º 5
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            _context.Cars.Add(Car);
            await _context.SaveChangesAsync();

            StatusMessage = "Car has been added successfully";
            return(RedirectToPage("Index", new { userId = Car.UserId }));
        }
Exemplo n.º 6
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());
            }

            var serviceType = await db.ServiceTypes.FindAsync(ServiceType.Id);

            serviceType.Name  = ServiceType.Name;
            serviceType.Price = ServiceType.Price;

            await db.SaveChangesAsync();

            return(RedirectToPage("./Index"));
        }
Exemplo n.º 7
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

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

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

            return(RedirectToPage("./Index"));
        }
Exemplo n.º 8
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            ServiceType = await _db.ServcieType.FindAsync(id);

            if (ServiceType != null)
            {
                // Remove from the context and then save those changes to the DB.
                _db.ServcieType.Remove(ServiceType);
                await _db.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }
Exemplo n.º 9
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Car = await _db.Car.FindAsync(id);

            if (Car != null)
            {
                _db.Car.Remove(Car);
                await _db.SaveChangesAsync();

                StatusMessage = Car.Model + " has been deleted Successfully";
            }

            return(RedirectToPage("Index", new { userId = Car.UserId }));
        }