コード例 #1
0
        public async Task <bool> Create(VehicleCheck entity)
        {
            if (entity == null)
            {
                return(false);
            }

            entity.Active       = true;
            entity.CreationDate = DateTime.Now;
            entity.UpdateDate   = DateTime.Now;

            try
            {
                await _dbContext.VehicleChecks.AddAsync(entity);

                var result = await _dbContext.SaveChangesAsync();

                if (result > 0)
                {
                    return(await _carRentInformationService.ChangeState(entity.CarRentInformationId,
                                                                        RentStateEnum.Active));
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                return(false);
            }

            return(false);
        }
コード例 #2
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            VehicleCheck = await _vehicleCheckService.GetSingleById(id.Value);

            if (VehicleCheck == null)
            {
                return(NotFound());
            }
            return(Page());
        }
コード例 #3
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

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

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

            return(RedirectToPage("./Index"));
        }
コード例 #4
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            VehicleCheck = await _context.VehicleCheck
                           .Include(v => v.CarRentInformation)
                           .Include(v => v.Employee)
                           .Include(v => v.FuelTank).FirstOrDefaultAsync(m => m.Id == id);

            if (VehicleCheck == null)
            {
                return(NotFound());
            }
            return(Page());
        }
コード例 #5
0
        public async Task <bool> Update(VehicleCheck entity)
        {
            if (entity == null)
            {
                return(false);
            }
            var entityToUpdate = await GetSingleById(entity.Id);

            entityToUpdate.FuelTankId      = entity.FuelTankId;
            entityToUpdate.HasBrokenWind   = entity.HasBrokenWind;
            entityToUpdate.HasJackScrew    = entity.HasJackScrew;
            entityToUpdate.HasScratch      = entity.HasScratch;
            entityToUpdate.HasSpare        = entity.HasSpare;
            entityToUpdate.LeftBottomTire  = entity.LeftBottomTire;
            entityToUpdate.LeftUpperTire   = entity.LeftUpperTire;
            entityToUpdate.RightBottomTire = entity.RightBottomTire;
            entityToUpdate.RightUpperTire  = entity.RightUpperTire;
            entityToUpdate.UpdateDate      = DateTime.Now;

            _dbContext.VehicleChecks.Update(entityToUpdate);
            var result = await _dbContext.SaveChangesAsync();

            return(result > 0);
        }