Ejemplo n.º 1
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());
        }
Ejemplo n.º 2
0
 public async Task <IActionResult> PostGroupProfile([FromBody] GroupProfile value)
 {
     if (!ModelState.IsValid)
     {
         return(BadRequest(ModelState));
     }
     else if (NameGroupProfileExists(value.Name))
     {
         return(new StatusCodeResult(StatusCodes.Status409Conflict));
     }
     try
     {
         _context.GroupProfile.Add(value);
         await _context.SaveChangesAsync();
     }
     catch (Exception e)
     {
         throw e;
     }
     return(CreatedAtAction("GetGroupProfile", new { id = value.Id }, value));
 }
Ejemplo n.º 3
0
        public async Task <IActionResult> PostGroupStatistic([FromBody] GroupStatisticViewModel groupStatistics)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            try
            {
                foreach (var model in groupStatistics.listModel)
                {
                    _context.GroupStatistic.Add(model);
                }

                await _context.SaveChangesAsync();
            }
            catch (Exception e)
            {
                return(NoContent());
            }
            return(Ok());
        }