// 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(TelemetryData).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!TelemetryDataExists(TelemetryData.IdTelemetryData))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(RedirectToPage("/Telemetry/Index", new { pageId = TelemetryData.CarId }));
        }
        // 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(Car).State = EntityState.Modified;
            _context.Entry(Car).Property(x => x.CreatedAt).IsModified = false;


            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CarExists(Car.CarId))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(RedirectToPage("./Index"));
        }
Example #3
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.Car.Add(Car);
            await _context.SaveChangesAsync();

            return(RedirectToPage("./Index"));
        }
        // 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.TelemetryData.Add(TelemetryData);
            await _context.SaveChangesAsync();

            return(RedirectToPage("/Telemetry/Index", new { pageId = TelemetryData.CarId }));
        }
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }



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

            int carId = TelemetryData.CarId;

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

            return(RedirectToPage("/Telemetry/Index", new { pageId = carId }));
        }
Example #6
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

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

            if (Car != null)
            {
                _context.TelemetryData
                .ToList()
                .Where(data => data.CarId == Car.CarId)
                .ToList()
                .ForEach(n => _context.TelemetryData.Remove(n));
                _context.Car.Remove(Car);
                await _context.SaveChangesAsync();
            }

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