// PUT api/cargo/5 public bool Put(int id, [FromBody] CargosEntity cargoEntity) { if (id > 0) { return(_cargoServices.UpdateCargo(id, cargoEntity)); } return(false); }
public int CreateCargo(CargosEntity cargoEntity) { using (var scope = new TransactionScope()) { var cargo = new Cargos { cgoDescripcion = cargoEntity.cgoDescripcion }; _unitOfWork.CargosRepository.Insert(cargo); _unitOfWork.Save(); scope.Complete(); return(cargo.cgoCargoId); } }
public bool UpdateCargo(int cargoid, CargosEntity cargoEntity) { var success = false; if (cargoEntity != null) { using (var scope = new TransactionScope()) { var cargo = _unitOfWork.CargosRepository.GetById(cargoid); if (cargo != null) { cargo.cgoDescripcion = cargoEntity.cgoDescripcion; _unitOfWork.CargosRepository.Update(cargo); _unitOfWork.Save(); scope.Complete(); success = true; } } } return(success); }
// POST api/cargo public int Post([FromBody] CargosEntity cargoEntity) { return(_cargoServices.CreateCargo(cargoEntity)); }