コード例 #1
0
 public async Task Create(ServicioPorProveedor model)
 {
     try
     {
         _db.ServicioPorProveedor.Add(model);
         await _db.SaveChangesAsync();
     }
     catch (Exception e)
     {
         throw new Exception(e.Message, e);
     }
 }
コード例 #2
0
        public async Task Update(ServicioPorProveedor model)
        {
            try
            {
                var _model = await _db.ServicioPorProveedor.FirstOrDefaultAsync(e => e.ServicioPorProveedorId == model.ServicioPorProveedorId);

                if (_model != null)
                {
                    _db.Entry(_model).CurrentValues.SetValues(model);
                    await _db.SaveChangesAsync();
                }
            }
            catch (Exception e)
            {
                throw new Exception(e.Message, e);
            }
        }
コード例 #3
0
        public async Task UpdateEstado(ServicioPorProveedor model)
        {
            try
            {
                var _model = await _db.ServicioPorProveedor.FirstOrDefaultAsync(e => e.ServicioPorProveedorId == model.ServicioPorProveedorId);

                if (_model != null)
                {
                    _model.Estado = model.Estado;

                    await _db.SaveChangesAsync();
                }
            }
            catch (Exception e)
            {
                throw new Exception(e.Message, e);
            }
        }
コード例 #4
0
                                                                  public async Task <IHttpActionResult> UpdateEstado([FromBody] ServicioPorProveedor model)
                                                                  {
                                                                      try { log.Info(new MDCSet(this.ControllerContext.RouteData));
                                                                            await _entityRepo.UpdateEstado(model);

                                                                            return(Ok()); }
                                                                      catch (Exception e) { log.Error(new MDCSet(this.ControllerContext.RouteData), e);

                                                                                            return(InternalServerError(e)); }
                                                                  }
コード例 #5
0
                                                                  public async Task <IHttpActionResult> Update([FromBody] ServicioPorProveedor model)
                                                                  {
                                                                      if (!ModelState.IsValid)
                                                                      {
                                                                          return(BadRequest(ModelState));
                                                                      }

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

                                                                            return(Ok("Registro actualizado exitosamente!")); }
                                                                      catch (Exception e) { log.Error(new MDCSet(this.ControllerContext.RouteData), e);
                                                                                            return(InternalServerError(e)); }
                                                                  }
コード例 #6
0
                                                                  [Authorize] public async Task <IHttpActionResult> Create([FromBody] ServicioPorProveedor 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)); }
                                                                  }