Exemplo n.º 1
0
                                                       [Authorize] public async Task <IHttpActionResult> Create([FromBody] Proveedor model)
                                                       {
                                                           if (!ModelState.IsValid)
                                                           {
                                                               return(BadRequest(ModelState));
                                                           }

                                                           try { log.Info(new MDCSet(this.ControllerContext.RouteData));
                                                                 await _entityRepo.Create(model);

                                                                 return(Ok("Registro creado exitosamente!")); }
                                                           catch (Exception e) { log.Error(new MDCSet(this.ControllerContext.RouteData), e);
                                                                                 if (e.Message.Substring(0, 44) == "An error occurred while updating the entries")
                                                                                 {
                                                                                     return(BadRequest("Ya existe un registro con ese nombre"));
                                                                                 }
                                                                                 return(InternalServerError(e)); }
                                                       }