Esempio n. 1
0
        public async Task <IActionResult> PutGroupProfile(int id, [FromBody] GroupProfile groupProfile)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            if (id != groupProfile.Id)
            {
                return(BadRequest());
            }

            try
            {
                var existingActivate = await _context.GroupProfile.Where(x => x.Status == true).SingleOrDefaultAsync();

                if (existingActivate != null && existingActivate.Id != id)
                {
                    existingActivate.Status = false;
                    _context.Entry(existingActivate).State = EntityState.Modified;
                }
                _context.Entry(groupProfile).State = EntityState.Modified;
                await _context.SaveChangesAsync();
            }
            catch (Exception e)
            {
                throw e;
            }
            return(NoContent());
        }
Esempio n. 2
0
        public async Task <IActionResult> PutFlightProfile([FromRoute] uint id, [FromBody] FlightProfile flightProfile)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != flightProfile.Id)
            {
                return(BadRequest());
            }

            _context.Entry(flightProfile).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!FlightProfileExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }