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

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

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

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

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

            try
            {
                if (file != null && file.Length > 0)
                {
                    _common.UploadImage(Vehicle, file);
                }

                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!VehicleExists(Vehicle.ID))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

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

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

            return(RedirectToPage("./Index"));
        }
Ejemplo n.º 4
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"));
        }
Ejemplo n.º 5
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

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

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

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

            if (file != null && file.Length > 0)
            {
                _common.UploadImage(Vehicle, file);
            }

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

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

            var emptyService = new Service();

            if (await TryUpdateModelAsync <Service>(
                    emptyService,
                    "service",
                    s => s.ID, s => s.VehicleID, s => s.ServiceTypeID, s => s.ServiceDate, s => s.ServiceVendor, s => s.Mileage))
            {
                _context.Service.Add(Service);
                await _context.SaveChangesAsync();

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

            PopulateVehicleNamesDropDownList(_context, emptyService.VehicleID);

            return(Page());
        }