Example #1
0
        public async Task PostPilotAsync(Models.Pilot pilot)
        {
            if (pilot == null)
            {
                throw new ArgumentNullException();
            }

            _paraContext.Pilots.Add(pilot);
            await _paraContext.SaveChangesAsync();
        }
Example #2
0
        public async Task <IActionResult> Create([Bind("ID,FirstName,LastName,Adress,PhoneNumber,Weight,PostitionID,IsActif")] Pilot pilot)
        {
            if (ModelState.IsValid)
            {
                _context.Add(pilot);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(pilot));
        }
        public async Task <IActionResult> Create([Bind("ID,Name,PilotID")] Role role)
        {
            if (ModelState.IsValid)
            {
                _context.Add(role);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["PilotID"] = new SelectList(_context.Pilots, "ID", "FirstName", role.PilotID);
            return(View(role));
        }
Example #4
0
        public async Task <bool?> UpdateParagliderAsync(int paragliderId, ParagliderPatchDto paragliderPatchDto)
        {
            var paragliderToUpdate = await _paraContext.Paragliders.FirstOrDefaultAsync(p => p.ID == paragliderId);

            if (paragliderToUpdate == null)
            {
                return(null);
            }

            paragliderToUpdate.Name             = paragliderPatchDto.Name;
            paragliderToUpdate.LastRevisionDate = paragliderPatchDto.LastRevision;

            return(await _paraContext.SaveChangesAsync() > 0);
        }
        public async Task <bool?> UpdateLevelAsync(int LevelId, LevelPatchDto patchDto)
        {
            var levelToUpdate = await _paraContext.Levels
                                .FirstOrDefaultAsync(p => p.ID == LevelId);

            if (levelToUpdate == null)
            {
                return(null);
            }

            levelToUpdate.Name  = patchDto.Name;
            levelToUpdate.Skill = patchDto.skill;

            return(await _paraContext.SaveChangesAsync() > 0);
        }
Example #6
0
        public async Task <bool?> UpdateSiteAsync(int id, SitePatchDto patchDto)
        {
            var siteToUpdate = await _paraContext.Sites
                               .FirstOrDefaultAsync(p => p.ID == id);

            if (siteToUpdate == null)
            {
                return(null);
            }

            siteToUpdate.Name              = patchDto.Name;
            siteToUpdate.Orientation       = patchDto.Orientation;
            siteToUpdate.SiteGeoCoordinate = patchDto.SiteGeoCoordinate;

            return(await _paraContext.SaveChangesAsync() > 0);
        }
Example #7
0
        public async Task <bool?> UpdateTraineeshipAsync(int traineeshipId, TraineeshipPatchDto patchDto)
        {
            var traineeshipToUpdate = await _paraContext.Traineeships
                                      .FirstOrDefaultAsync(p => p.ID == traineeshipId);

            if (traineeshipToUpdate == null)
            {
                return(null);
            }

            traineeshipToUpdate.StartDate = patchDto.TraineeShipStartDate;
            traineeshipToUpdate.EndDate   = patchDto.TraineeShipEndDate;
            traineeshipToUpdate.Price     = patchDto.TraineeShipPrice;

            return(await _paraContext.SaveChangesAsync() > 0);
        }