Beispiel #1
0
        public async Task <IActionResult> PutLogEntry([FromRoute] int id, [FromBody] LogEntry logEntry)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != logEntry.LogEntryId)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Beispiel #2
0
        public async Task <Response> PutLogCategory([FromBody] LogCategory logCategory)
        {
            if (!ModelState.IsValid)
            {
                return(new entidades.Response
                {
                    IsSuccess = false,
                    Message = "Módelo inválido",
                });
            }
            db.Entry(logCategory).State = EntityState.Modified;

            try
            {
                var respuesta = Existe(logCategory);
                if (!respuesta.IsSuccess)
                {
                    await db.SaveChangesAsync();

                    return(new entidades.Response
                    {
                        IsSuccess = true,
                        Message = "Ok",
                    });
                }
                return(new entidades.Response
                {
                    IsSuccess = false,
                    Message = "Existe un Log Category de igual Nombre...",
                });
            }
            catch (Exception ex)
            {
                return(new entidades.Response
                {
                    IsSuccess = false,
                    Message = "Existe un Log Category de igual Nombre...",
                });
            }
        }