public ActionResult Details([Bind(Include = "Id,Identifier,Emeil")] CargoModel model) { Carrier carrier = null; try { carrier = db.Carriers.Where(c => c.CarrierIdentificator == model.Identifier && c.Emeil == model.Emeil).First(); } catch (InvalidOperationException) { return(RedirectToAction("ErrorUser")); throw; } Cargo cargo = db.Cargoes.Where(c => c.CargoId == model.Id).First(); if (carrier == null) { return(RedirectToAction("AllCargoes")); } carrier.Cargoes.Add(cargo); cargo.CarrierId = carrier.CarrierId; db.SaveChanges(); return(RedirectToAction("AddedCargo")); }
List <CargoModel> MontaRetorno(DataSet data) { List <CargoModel> retorno; CargoModel objAux; try { retorno = new List <CargoModel>(); for (int i = 0; i < data.Tables[0].Rows.Count; i++) { objAux = new CargoModel(); objAux.ID = Convert.ToInt32(data.Tables[0].Rows[i]["id"]); objAux.Vagas = Convert.ToInt32(data.Tables[0].Rows[i]["Vagas"]); objAux.Pontuacao = Convert.ToInt32(data.Tables[0].Rows[i]["Pontuacao"]); objAux.Tempo = Convert.ToInt32(data.Tables[0].Rows[i]["Tempo"]); objAux.Cargo = data.Tables[0].Rows[i]["Cargo"].ToString(); retorno.Add(objAux); objAux = null; } return(retorno); } catch (Exception ex) { throw ex; } }
public async Task <ActionResult <CargoModel> > PostCargoModel(CargoModel cargoModel) { _context.CargoModels.Add(cargoModel); await _context.SaveChangesAsync(); return(CreatedAtAction(nameof(GetCargoModel), new { id = cargoModel.IdCargo }, cargoModel)); }
public async Task <IActionResult> PutCargoModel(int id, CargoModel cargoModel) { if (id != cargoModel.IdCargo) { return(BadRequest()); } _context.Entry(cargoModel).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CargoModelExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public List <CargoModel> Sender() { logger.Debug("Загрузка сохранённого файла"); Loader(); using (var context = new DBContext()) { logger.Debug("Контекст БД начинает заполняться элементами для отправки"); for (int i = 0; i < dll.LocalList.Count; i++) { var wagon = new CargoModel() { ShippingDate = dll.LocalList[i].ShippingDate, TCNumber = dll.LocalList[i].TCNumber, WaybillNumber = dll.LocalList[i].WaybillNumber, Cargo = dll.LocalList[i].Cargo, Mark = dll.LocalList[i].Mark, Station = dll.LocalList[i].Station, NetWeight = dll.LocalList[i].NetWeight, GrossWeight = dll.LocalList[i].GrossWeight, DTNumber = dll.LocalList[i].DTNumber, Addressee = dll.LocalList[i].Addressee, ShipmentDateTo = dll.LocalList[i].ShipmentDateTo, ShipmentDateFrom = dll.LocalList[i].ShipmentDateFrom }; context.ParsData.Add(wagon); context.SaveChanges(); } logger.Debug("Данные успешно заполнены и отправлены в БД"); return(null); } }
private void insertarCargo() { if (!string.IsNullOrEmpty(txtCargoG.Text)) { if (!string.IsNullOrEmpty(txtSueldoG.Text)) { CargoModel parametros = new CargoModel(); CargoController funcion = new CargoController(); parametros.cargo = txtCargoG.Text; parametros.sueldoPorHora = Convert.ToDouble(txtSueldoG.Text); if (funcion.insertarCargo(parametros) == true) { txtCargoG.Clear(); buscarCargo(); PanelCargos.Visible = false; } } else { MessageBox.Show("Agregue el sueldo", "Falta el sueldo", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { MessageBox.Show("Agregue el cargo", "Falta el cargo", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
public TableProjectionExpression(CargoModel model, string tableAlias) { Debug.Assert(model != null); Debug.Assert(!string.IsNullOrEmpty(tableAlias)); Model = model; TableAlias = tableAlias; }
public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Cargo cargo = db.Cargoes.Where(c => c.CargoId == id).First(); if (cargo == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CargoModel model = new CargoModel(); model.Id = cargo.CargoId; model.Name = cargo.Name; model.PricePerKilometer = cargo.PricePerKilometer; Location fromLocation = db.Locations.Where(l => l.LocationId == cargo.FromLocationId).First(); Location forLocation = db.Locations.Where(l => l.LocationId == cargo.ForLocationId).First(); model.FromLocation = fromLocation.Name; model.ForLocation = forLocation.Name; model.Weight = cargo.Weight; model.CargoType = cargo.CargoType.ToString(); model.TransportType = cargo.TransportType.ToString(); return(View(model)); }
public JsonResult SalvarCargo(CargoModel model) { var resultado = "OK"; var mensagens = new List <string>(); var idSalvo = string.Empty; if (!ModelState.IsValid) { resultado = "AVISO"; mensagens = ModelState.Values.SelectMany(x => x.Errors).Select(x => x.ErrorMessage).ToList(); } else { try { if (model.Salvar() != 0) { // ok } else { resultado = "ERRO"; } } catch (Exception) { resultado = "ERRO"; } } //objeto anonimo return(Json(new { Resultado = resultado, Mensagens = mensagens, IdSalvo = idSalvo })); }
public async Task <int> Add(CargoModel model) { var entity = _mapper.Map <CargoEntity>(model); var entityDb = await(Task <CargoEntity>) _cargoRepository.Insert(entity).Result.Entity; _uow.SaveChanges(); return(entityDb.Id); }
public CargoModel GetCargoInfo(uint cargoID) { string where = string.Format("`cargo`.`cargoid`={0}", cargoID); CargoModel merchantInfo = db.SelectData <CargoModel>("cargo", where)[0]; return(merchantInfo); }
public void Remove(CargoModel cargo) { using (ISession session = NHibernateHelper.OpenSession()) using (ITransaction transaction = session.BeginTransaction()) { session.Delete(cargo); transaction.Commit(); } }
public CadCargoWin(CargoModel cargo) { InitializeComponent(); Iniciar(); this.cargo = cargo; Title = "EDITAR CARGO"; CarregarDados(); }
public async Task <HttpStatusCode> UpdateCargoAsync(CargoModel model) { HttpResponseMessage response = await client.PutAsync( $"{URL}/{model.Cargo_Id}", new StringContent(JsonConvert.SerializeObject(model), Encoding.UTF8, "application/json")); response.EnsureSuccessStatusCode(); return(response.StatusCode); }
public void AtualizarCargo(CargoModel p_obj) { try { RepoCargo.Update(p_obj); } catch (Exception ex) { throw ex; } }
// GET: Crear Cargo public ActionResult Crear() { if (Session["Key"] == null) { return(RedirectToAction("../Login/Index")); } CargoModel cargo = new CargoModel(); return(View(cargo)); }
private void Inicializar() { cargos = CargoModel.CarregarTodos(); cbCargo.ItemsSource = cargos; cbUf.ItemsSource = EstadoModel.Siglas; AdicionarEventos(); Loaded += (o, a) => tbNome.Focus(); }
/// <summary> /// Initialize a query expression from the specified model. /// </summary> /// <param name="model"></param> public CargoQueryExpression(CargoModel model) { const string tableAlias = "T0"; RecordType = model.ClrType; Fields = model.Properties.Select(p => new ProjectionExpression(new FieldRefExpression(tableAlias, p), ProjectionExpression.MangleAlias(p.Name), p.ClrProperty) ).ToImmutableList(); Tables = ImmutableList.Create(new TableProjectionExpression(model, tableAlias)); aliasProjectionDict = Fields.ToDictionary(f => f.Alias); }
public async Task <int> Add([FromBody] CargoModel model) { try { return(await _cargoService.Add(model)); } catch (Exception ex) { throw new Exception(ex.Message); } }
public ActionResult Index() { var usuarioLogado = ObtenhaUsuarioPornome(HttpContext.User.Identity.Name); ViewBag.ListaPerfil = PerfilModel.RecuperarListaAtivos(); ViewBag.ListaCargo = CargoModel.RecuperarListaCargo(); ViewBag.SenhaPadrao = _senhaPadrao; var lista = UsuarioModel.RecuperarLista(usuarioLogado); return(View(lista)); }
public async Task <IActionResult> UpdateCargo(CargoModel cargo) { // Repensar em como fazer aqui if (!ModelState.IsValid) { throw new Exception("Propriedades Inválidas"); } await _cargoService.UpdateCargoAsync(cargo); return(RedirectToAction("Index")); }
public IActionResult CreateCargo([FromBody] CargoModel model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var cargo = _mapper.Map <Cargo>(model); model.Cargo_Id = _cargoRepository.CreateCargo(cargo); return(Ok(model)); }
private void CarregarCargos() { if (string.IsNullOrEmpty(tbPesquisa.Text)) { cargos = CargoModel.CarregarTodos(); } else { cargos = CargoModel.Pesquisar(tbPesquisa.Text); } lvwCargos.ItemsSource = cargos; tbPesquisa.Focus(); }
public void Update(CargoModel cargoModel) { try { Comando = "Update tbCargo set "; Comando = Comando + " Vagas = " + cargoModel.Vagas; Comando = Comando + " Where Cargo = '" + cargoModel.Cargo + "'"; objDados.ExecutaComando(Comando); } catch (Exception ex) { throw ex; } }
public void AddCargo(string cargoPlate, string cargoDriver, string driverLicence, string cargoContact, string cargoDescription, uint marketID, uint?cargoOwnerID) { CargoModel cargo = new CargoModel(); cargo.plate = cargoPlate; cargo.driver = cargoDriver; cargo.licence = driverLicence; cargo.contact = cargoContact; cargo.description = cargoDescription; cargo.marketid = marketID; cargo.aid = cargoOwnerID; db.InsertSingleLine <CargoModel>("cargo", cargo); }
// GET: Ver Modificar Cargo public ActionResult Editar(int mCodigo) { if (Session["Key"] == null) { return(RedirectToAction("../Login/Index")); } Cargo car = CargoBrl.Get(mCodigo); CargoModel model = new CargoModel() { IdCargo = car.IdCargo, Nombre = car.Nombre, }; return(View(model)); }
private void editarCargos() { CargoModel parametros = new CargoModel(); CargoController funcion = new CargoController(); parametros.idCargo = idCargo; parametros.cargo = txtCargoG.Text; parametros.sueldoPorHora = Convert.ToDouble(txtSueldoG.Text); if (funcion.actualizarCargo(parametros) == true) { txtCargo.Clear(); buscarCargo(); PanelCargos.Visible = false; } }
public ActionResult Crear(CargoModel model) { try { Cargo cargo = new Cargo() { Nombre = model.Nombre, }; CargoBrl.Insertar(cargo); return(RedirectToAction("../Cargo/Index")); } catch { return(View()); } }
public ActionResult Editar(int id) { CargoModel model = null; try { var Cargo = _CargoBusiness.Obter(id); model = SimpleMapper.Map <Cargo, CargoModel>(Cargo); } catch (Exception e) { TempData["Erro"] = e.Message; return(RedirectToAction("Index")); } return(View(model)); }
public IActionResult CreateCargo([FromBody] CargoModel model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var cargo = new Cargo { CargoDesc = model.Cargo_Desc }; var newCargo = _cargoRepository.CreateCargo(cargo); model.Cargo_Id = newCargo.CargoId; return(Ok(model)); }