public void AdquirirOferta(Cliente cliente, Oferta oferta) { cliente.Oferta = oferta; cliente.PlanoPagamentoCliente = CriarPlanoPagamentoPorInfoPagamentoOferta(oferta); CriarCobrancas(cliente.PlanoPagamentoCliente); cliente.StatusCliente = StatusCliente.AguardandoPagamento; SalvarCliente(cliente); }
public Oferta CriarOferta(int numeroParcelas, decimal valorEntrada, decimal valorVenda) { InfoPagamento infoPagamento = new InfoPagamento(); infoPagamento.NumeroParcelas = numeroParcelas; infoPagamento.Entrada = valorEntrada; infoPagamento.ValorTotalPlano = valorVenda; Oferta oferta = new Oferta(); oferta.DataInicioOferta = DateTime.Now; oferta.InfoPagamento = infoPagamento; return oferta; }
public PlanoPagamento CriarPlanoPagamentoPorInfoPagamentoOferta(Oferta oferta) { InfoPagamento infoPagamento = oferta.InfoPagamento; var valorTotalParcelado = infoPagamento.ValorTotalPlano - infoPagamento.Entrada; var valorPorParcela = valorTotalParcelado / infoPagamento.NumeroParcelas; PlanoPagamento planoPagamento = new PlanoPagamento(); ItemPlanoPagamento itemPlanoPagamento = null; planoPagamento.Entrada = infoPagamento.Entrada; for (int i = 0; i < infoPagamento.NumeroParcelas; i++) { itemPlanoPagamento = CriarItemPlanoPagamento(valorPorParcela); planoPagamento.ItensPlanoPagamento.Add(itemPlanoPagamento); } return planoPagamento; }
private void txtAceptar_Click(object sender, EventArgs e) { int valor; if (int.TryParse(txtOferta.Text, out valor)) { if (valor > ofertaMasGrande) { Oferta oferta = new Oferta(publicacion.ID_Vendedor, Interfaz.usuario.ID_User, publicacion.Cod_Publicacion, 1, valor); Oferta.insertarOferta(oferta); MessageBox.Show("Oferta realizada con éxito! Actualmente usted tiene la oferta mas alta.", "Succes!", MessageBoxButtons.OK, MessageBoxIcon.None); ofertaMasGrande = valor; txtOfertaActual.Text = Convert.ToString(valor); } else MessageBox.Show("Por favor ingrese un valor numerico entero, mayor que la oferta actual.", "ATENCIÓN!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else { MessageBox.Show("Por favor ingrese un valor numerico entero, mayor que la oferta actual.", "ATENCIÓN!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
public async Task <ActionResult <Oferta> > Put(int id, [FromForm] Oferta oferta) { if (id != oferta.IdOferta) { return(BadRequest("Oferta não encontrada")); } try { var arquivo = Request.Form.Files[0]; oferta.Quantidade = int.Parse(Request.Form["quantidade"]); oferta.Foto = _uploadRepo.Upload(arquivo, "imgOferta"); oferta.Cor = Request.Form["cor"].ToString(); oferta.Preco = double.Parse(Request.Form["preco"]); oferta.Descricao = Request.Form["descricao"].ToString(); oferta.DataValidade = DateTime.Parse(Request.Form["dataValidade"]); oferta.IdProduto = int.Parse(Request.Form["idProduto"]); oferta.IdUsuario = int.Parse(Request.Form["idUsuario"]); oferta.Titulo = Request.Form["titulo"].ToString(); oferta.CheckDoacao = Request.Form["checkDoacao"].ToString(); oferta.DoacaoOng = int.Parse(Request.Form["doacaoOng"]); await _repositorio.Alterar(oferta); } catch (DbUpdateConcurrencyException) { var oferta_valida = await _repositorio.BuscarPorID(id); if (oferta_valida == null) { return(NotFound("Oferta não encontrada")); } else { throw; } } return(oferta); }
public Oferta searchOfertabyId(int id) { SqlCommand cmd_oferta = new SqlCommand("SELECT * FROM GESTION_BDD_2C_2019.OFERTA where id = '" + id + "'", ConnectionQuery.Instance()); ConnectionQuery.abrirConexion(); SqlDataReader r_rol = cmd_oferta.ExecuteReader(); Oferta oferta = new Oferta(); if (r_rol.Read()) { oferta.id = Convert.ToInt32(r_rol["ID"]); oferta.idold = Convert.ToString(r_rol["IDold"]); oferta.proovedorId = Convert.ToInt32(r_rol["PROV_ID"]); oferta.precio = Convert.ToInt64(r_rol["PRECIO"]); oferta.precioLista = Convert.ToInt64(r_rol["PRECIO_LISTO"]); oferta.stockDisponible = Convert.ToInt32(r_rol["STOCK_DISPONIBLE"]); oferta.fechaPublicacion = (DateTime)r_rol["FECHA_PUBLIC"]; oferta.fechaVencimiento = (DateTime)r_rol["FECHA_VENC"]; oferta.cantidadMaximaPorCompra = Convert.ToInt32(r_rol["MAX_X_COMPRA"]); oferta.descripcion = Convert.ToString(r_rol["DESCRIPCION"]); } ConnectionQuery.cerrarConexion(); return(oferta); }
public static void EnviarEmailLimiteOferta(Oferta oferta, MatriculaOferta matriculaOferta) { try { var template = TemplateUtil.ObterInformacoes(enumTemplate.NotificacaoLimiteOferta); var assuntoDoEmail = template.Assunto; var textoEmail = template.TextoTemplate; textoEmail = textoEmail .Replace("#NOMESOLUCAOEDUCACIONAL#", matriculaOferta.Oferta.SolucaoEducacional.Nome) .Replace("#NOMEOFERTA#", matriculaOferta.Oferta.Nome) .Replace("#QTDINSCRITOSOFERTA#", oferta.ListaMatriculaOferta.Count.ToString()); EmailUtil.Instancia.EnviarEmail(oferta.EmailResponsavel, assuntoDoEmail, textoEmail); } catch { //NADA A FAZER } }
private void lblOfertar_Click(object sender, EventArgs e) { try { if (SessionManager.CurrentRol.Descripcion == "Administrador General") { throw new Exception("Siendo un administrador no puede comprar ni ofertar"); } List <PublicacionNotCalified> publications = CalificacionPersistance.GetAllPubicacionNotCalified(SessionManager.CurrentUser); if (publications.Count > 5) { throw new Exception("Tiene demasiadas compras sin calificar, por favor califíquelas para poder realizar una compra"); } //Valido que la oferta sea mayor a la última if (txtMonto.Text == "" || Int32.Parse(txtMonto.Text) <= Int32.Parse(lblPrecio.Text)) { throw new Exception("El monto a ofertar debe ser mayor que la oferta actual"); } //Creo la nueva oferta y la inserto Oferta newOffer = new Oferta(); newOffer.IdUsuario = SessionManager.CurrentUser.ID; newOffer.IdPublicacion = CurrentPublication.ID; newOffer.Fecha = ConfigurationVariables.FechaSistema; newOffer.Monto = Int32.Parse(txtMonto.Text); newOffer = OfertaPersistance.Insert(newOffer, null); MessageBox.Show("Se insertó la oferta correctamente"); RefreshSources(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public static Oferta Buscar(int dia) { ConexBD con = new ConexBD(); con.Conectar(); Oferta oferta = new Oferta(); MySqlCommand cmd = new MySqlCommand("ofertasDelDia", con.ObtenerConexion()); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add(new MySqlParameter("dia", dia)); MySqlDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection); while (dr.Read()) { oferta.idOferta = Convert.ToInt32(dr["id"]); oferta.Nombre = Convert.ToString(dr["nombre"]); oferta.Porcentaje = Convert.ToDecimal(dr["porcentaje"]); oferta.Prendas = Convert.ToString(dr["tipos_prenda"]); oferta.Cantidad = Convert.ToInt32(dr["cantidad"]); oferta.PorcentajeVisa = Convert.ToInt32(dr["porcentajeVisa"]); } con.cerrarConexion(); return(oferta); }
private void btn_Guardar_Click(object sender, EventArgs e) { int num; bool esNumero = int.TryParse(txtCantDisponible.Text, out num); bool esNumero1 = int.TryParse(txtMaxCantUsuario.Text, out num); if (esNumero && esNumero1) { try { if (this.agregando == 1) { int idProv = RepoProveedores.instance().getIdProveedor(cboProveedor.Text); Oferta oferta = new Oferta(txtId.Text, txtDescripcion.Text, Convert.ToDateTime(txtFechaInicio.Text), Convert.ToDateTime(txtFechaVenc.Text), Convert.ToDouble(txtPrecioOferta.Text), Convert.ToDouble(txtPrecioLista.Text), idProv, Convert.ToInt32(txtCantDisponible.Text), Convert.ToInt32(txtMaxCantUsuario.Text)); PresenterProveedor.instance().nuevaOferta(oferta); this.reiniciarTodo(); } else { int idProv = RepoProveedores.instance().getIdProveedor(cboProveedor.Text); Oferta oferta = new Oferta(txtId.Text, txtDescripcion.Text, Convert.ToDateTime(txtFechaInicio.Text), Convert.ToDateTime(txtFechaVenc.Text), Convert.ToDouble(txtPrecioOferta.Text), Convert.ToDouble(txtPrecioLista.Text), idProv, Convert.ToInt32(txtCantDisponible.Text), Convert.ToInt32(txtMaxCantUsuario.Text)); PresenterProveedor.instance().editarOferta(oferta); this.reiniciarTodo(); } } catch (Exception ex) { MessageBox.Show(ex.Message); btn_Guardar.Enabled = true; } } else { MessageBox.Show("Ingrese datos validos"); } }
public static List <Oferta> getOfertasNoVencidas() { SqlConnection con = new SqlConnection(Conexion.getStringConnection()); con.Open(); string sql = "SELECT * FROM [NO_SRTA_E_GATOREI].OFERTAS WHERE @FECHA_SISTEMA < FECHA_VENCIMIENTO"; SqlCommand cmd = new SqlCommand(sql, con); cmd.Parameters.AddWithValue("@FECHA_SISTEMA", Utils.HoraSistema.get()); SqlDataReader reader = cmd.ExecuteReader(); List <Oferta> ofertas = new List <Oferta>(); while (reader.Read()) { Oferta o = new Oferta(); o.id = reader.GetInt32(reader.GetOrdinal("OFERTA_ID")); o.precio_lista = reader.GetDecimal(reader.GetOrdinal("PRECIO_LISTA")); o.precio_oferta = reader.GetDecimal(reader.GetOrdinal("PRECIO_OFERTA")); o.fecha_publicacion = reader.GetDateTime(reader.GetOrdinal("FECHA_PUBLICACION")); o.fecha_vencimiento = reader.GetDateTime(reader.GetOrdinal("FECHA_VENCIMIENTO")); o.cantidad = reader.GetDecimal(reader.GetOrdinal("CANTIDAD")); o.maximo_usuario = reader.GetDecimal(reader.GetOrdinal("MAXIMO_USUARIO")); o.descripcion = reader.GetString(reader.GetOrdinal("DESCRIPCION")); o.codigo = reader.GetString(reader.GetOrdinal("CODIGO")); o.proveedor_id = reader.GetInt32(reader.GetOrdinal("PROVEEDOR_ID")); ofertas.Add(o); } con.Close(); return(ofertas); }
public static void UpdateOferta(Oferta objOferta) { UpdateOferta(objOferta.id_Ofertas, objOferta.nombre, objOferta.fechaInicio, objOferta.fechaFin, objOferta.descripcion, objOferta.intIdUsuarioModificacion); }
public static int InsertObjetoOferta(Oferta objOferta) { return(InsertDatosOferta(objOferta.nombre, objOferta.fechaInicio, objOferta.fechaFin, objOferta.descripcion, objOferta.intIdUsuarioCreacion)); }
private OfertaDTO OfertaToDTO(Oferta o) { if (o == null) { return null; } OfertaDTO oferta = new OfertaDTO(); //oferta.Anunciante = AnuncianteToDTO(o.Anunciante); oferta.Condicoes = o.Condicoes; oferta.DataExpiracao = o.DataExpiracao; oferta.DataInicioValidade = o.DataInicioValidade; oferta.DataPublicacao = o.DataPublicacao; oferta.DataValidadeCupons = o.DataValidadeCupons; oferta.Descricao = o.Descricao; oferta.Id = o.Id; oferta.NumeroMaximoCupons = o.NumeroMaximoCupons; oferta.Status = o.Status; oferta.ValorCupons = o.ValorCupons; oferta.CuponsGerados = new List<CupomDTO>(); oferta.Endereco = o.Endereco; oferta.Telefone = o.Telefone; if (o.CuponsGerados != null && o.CuponsGerados.Count != 0) { o.CuponsGerados.ForEach(c => { CupomDTO cupom = new CupomDTO(); cupom = CupomToDTO(c); oferta.CuponsGerados.Add(cupom); }); } return oferta; }
String IDAOOferta.disponibilidadOferta(Entidad e, int disponibilidad) { Oferta oferta = (Oferta)e; int ofertaId = oferta._idOferta; Debug.WriteLine("Enró a DAO DISPON OFERTA"); Debug.WriteLine("Enró a DAO DISPON OFERTA " + disponibilidad); Debug.WriteLine("Enró a DAO DISPON OFERTA " + ofertaId); SqlConnection conexion = new SqlConnection(_connexionString); try { conexion.Open(); SqlCommand cmd = new SqlCommand("[dbo].[M11_ActualizarOferta]", conexion); cmd.CommandType = CommandType.StoredProcedure; Debug.WriteLine("HIZO CONEXIÓN EN VISUAL"); SqlParameter ParId = new SqlParameter(); ParId.ParameterName = "@ofe_id"; ParId.SqlDbType = SqlDbType.Int; ParId.Value = ofertaId; cmd.Parameters.Add(ParId); SqlParameter ParEstado = new SqlParameter(); ParEstado.ParameterName = "@ofe_estado"; ParEstado.SqlDbType = SqlDbType.Int; ParEstado.Value = disponibilidad; cmd.Parameters.Add(ParEstado); using (SqlDataReader reader = cmd.ExecuteReader()) { cmd.Dispose(); conexion.Close(); return("Realizado el Cambio. Actualice la página."); } } catch (SqlException ex) { Debug.WriteLine("Ocurrio un SqlException"); Debug.WriteLine(ex.ToString()); conexion.Close(); return("SQL EXCEPTION"); } catch (NullReferenceException ex) { Debug.WriteLine("Ocurrio una NullReferenceException"); Debug.WriteLine(ex.ToString()); conexion.Close(); return("Ocurrio una NullReferenceException"); } catch (ArgumentNullException ex) { Debug.WriteLine("Ocurrio una ArgumentNullException"); Debug.WriteLine(ex.ToString()); conexion.Close(); return("Ocurrio una ArgumentNullException"); } catch (Exception ex) { Debug.WriteLine("Ocurrio una Exception"); Debug.WriteLine(ex.ToString()); conexion.Close(); return("Ocurrio una Exception desconocida"); } }
public void Inserir(Oferta oferta) { context.Oferta.Add(oferta); context.SaveChanges(); }
public Boolean eliminarImagenesOfertaPorOferta(Oferta oferta) { return(imagenesOfertaDao.eliminarImagenesOfertaPorOferta(oferta)); }
public void Verificar_Oferta_Obrigatoria() { string nomeoferta = "Curso SPrev 2019"; Oferta oferta = new Oferta(nomeoferta); }
public async void AddContact(Oferta oferta) { await _table.InsertAsync(oferta); await SyncAsync(); }
public void nuevaOferta(Oferta oferta) { RepoOferta.instance().agregarOferta(oferta); MessageBox.Show("Oferta Agregada"); }
public void Update(Oferta actualizarOferta) { _context.Update(actualizarOferta); _context.SaveChanges(); }
public void Add(Oferta nuevaOferta) { _context.Add(nuevaOferta); _context.SaveChanges(); }
private void ObtenerOfertaActual() { ofertaActual = RepositorioOferta.Instance.BuscarOferta(publicacionAOfertar.publicacion_id); }
public void Delete(Oferta eliminarOferta) { _context.Remove(eliminarOferta); }
public ActionResult CreateOferta([Bind(Include = "id,Monto")] Oferta oferta, double monto_actual)//,id_Usuario,fecha { var user = Session["usuario"] as UsuarioSite; valor_tenant = user.Dominio; var idOfertante = _blusuario.ObtenerIdByEmail(valor_tenant, user.Email); var ofertante = _blusuario.GetUsuario(valor_tenant, idOfertante); if (monto_actual >= oferta.Monto) { ModelState.AddModelError("", "La Oferta debe ser mayor a " + monto_actual); return(View()); } else if (ofertante.billetera < oferta.Monto) { ModelState.AddModelError("", "Error usted solo dispone de $" + ofertante.billetera); return(View()); } else { user = Session["usuario"] as UsuarioSite; valor_tenant = user.Dominio; oferta.id_Subasta = idSub; oferta.fecha = DateTime.Now; oferta.id_Usuario = ofertante.id; _bloferta.AgregarOferta(valor_tenant, oferta); if (_blsubasta.ActualizarMonto(valor_tenant, oferta.id_Subasta, oferta.Monto)) { var lista = _bloferta.ObtenerOfertasByProducto(valor_tenant, idSub); List <OfertaModel> listOfer = new List <OfertaModel>(); foreach (var item in lista) { OfertaModel ofert = new OfertaModel(); ofert.id = item.id; try { ofert.nombre = _blusuario.GetNombreUsuario(valor_tenant, item.id_Usuario); } catch (Exception) { throw; } ofert.id_Subasta = item.id_Subasta; ofert.id_Usuario = item.id_Usuario; ofert.Monto = item.Monto; ofert.fecha = item.fecha; listOfer.Add(ofert); } try { _bloferta.correoOferta(valor_tenant, oferta); } catch (Exception) { throw; } ViewBag.ListaOfertas = listOfer; } } return(View("Index")); }
public void MatricularSolucaoEducacional(int idUsuario, int idSolucaoEducacional, int idOferta, List <int> pListaIdMetaIndividualAssociada, List <int> pListaIdMetaInstitucionalAssociada, AuthenticationRequest autenticacao) { Usuario userSelected = new BMUsuario().ObterPorId(idUsuario); SolucaoEducacional solucaoEducacional = new BMSolucaoEducacional().ObterPorId(idSolucaoEducacional); BMMatriculaOferta moBM = new BMMatriculaOferta(); if (solucaoEducacional == null) { throw new AcademicoException("Solução Educacional não encontrada"); } //VALIDAR SE ELE TEM ALGUMA OFERTA EXCLUSIVA PENDENTE DE CONFIRMACAO if (userSelected.ListaMatriculaOferta.Any(x => x.Oferta.ID == idOferta && x.Oferta.SolucaoEducacional.ID == idSolucaoEducacional && x.StatusMatricula == enumStatusMatricula.PendenteConfirmacaoAluno && x.Oferta.DataFim.Value.Date >= DateTime.Now.Date)) { MatriculaOferta mo = userSelected.ListaMatriculaOferta.Where(x => x.Oferta.SolucaoEducacional.ID == idSolucaoEducacional && x.StatusMatricula == enumStatusMatricula.PendenteConfirmacaoAluno).FirstOrDefault(); if (mo != null) { mo.StatusMatricula = enumStatusMatricula.Inscrito; mo.Auditoria = new Auditoria(autenticacao.Login); moBM.Salvar(mo); ValidarMetaIndividual(idUsuario, idSolucaoEducacional, pListaIdMetaIndividualAssociada, autenticacao); ValidarMetaInstitucional(idUsuario, idSolucaoEducacional, pListaIdMetaInstitucionalAssociada, autenticacao); if (!(mo.MatriculaTurma != null && mo.MatriculaTurma.Count > 0)) { try { if (mo.Oferta.TipoOferta.Equals(enumTipoOferta.Continua)) { string retornows; switch (mo.Oferta.SolucaoEducacional.Fornecedor.ID) { case (int)enumFornecedor.MoodleSebrae: moodle.IntegracaoSoapClient soapCliente = new moodle.IntegracaoSoapClient(); retornows = soapCliente.MatricularAluno( userSelected.Nome, userSelected.CPF, userSelected.Email, userSelected.Cidade, mo.Oferta.SolucaoEducacional.IDChaveExterna.ToString(), mo.MatriculaTurma.FirstOrDefault().Turma.IDChaveExterna.ToString()); break; case (int)enumFornecedor.WebAula: Turma turma = mo.MatriculaTurma.FirstOrDefault().Turma; webaula.waIntegracaoSoapClient wa = new webaula.waIntegracaoSoapClient(); webaula.AuthenticationProviderRequest aut = new webaula.AuthenticationProviderRequest(); webaula.DTOUsuario dtoUsuario = new webaula.DTOUsuario(); webaula.DTOTurma dtoTurma = new webaula.DTOTurma(); dtoTurma.IDChaveExterna = turma.IDChaveExterna; dtoUsuario.CPF = userSelected.CPF; dtoUsuario.Email = userSelected.Email; dtoUsuario.Nome = userSelected.Nome; dtoUsuario.Sexo = userSelected.Sexo; dtoUsuario.UF = userSelected.UF.Sigla; aut.Login = mo.Oferta.SolucaoEducacional.Fornecedor.Login; aut.Senha = CriptografiaHelper.Decriptografar(mo.Oferta.SolucaoEducacional.Fornecedor.Senha); retornows = wa.Matricular(aut, dtoUsuario, dtoTurma); break; } } } catch (Exception ex) { ErroUtil.Instancia.TratarErro(ex); } } if (!string.IsNullOrEmpty(mo.Usuario.Email)) { Template mensagemRecuperacaoDeSenhaSemConfirmacao = TemplateUtil.ObterInformacoes(enumTemplate.InscricaoSESucesso); string assuntoDoEmail = mensagemRecuperacaoDeSenhaSemConfirmacao.DescricaoTemplate.Substring(0, mensagemRecuperacaoDeSenhaSemConfirmacao.DescricaoTemplate.IndexOf(Environment.NewLine)); Dictionary <string, string> registros = new Dictionary <string, string>(); registros.Add("NOMESOLUCAOEDUCACIONAL", mo.Oferta.SolucaoEducacional.Nome); registros.Add("DATASISTEMA", DateTime.Now.ToString("dd'/'MM'/'yyyy HH:mm")); registros.Add("NOMEALUNO", mo.Usuario.Nome); //Envia e-mail para o usuário EmailUtil.Instancia.EnviarEmail(mo.Usuario.Email, assuntoDoEmail, this.FormatarTextoEmail(registros, mensagemRecuperacaoDeSenhaSemConfirmacao.DescricaoTemplate) ); } return; } } //Verificando se existe alguma matricula na SE. MatriculaOferta buscaMatricula = new MatriculaOferta(); buscaMatricula.Usuario = new Usuario(); buscaMatricula.Usuario.ID = userSelected.ID; List <MatriculaOferta> possiveisMatriculas = new BMMatriculaOferta().ObterPorFiltro(buscaMatricula).ToList(); if (possiveisMatriculas != null && possiveisMatriculas.Any(y => y.Oferta.SolucaoEducacional.ID == idSolucaoEducacional && !(y.StatusMatricula == enumStatusMatricula.CanceladoAdm || y.StatusMatricula == enumStatusMatricula.CanceladoAluno))) { throw new AcademicoException("Erro: O usuário já está matriculado em uma oferta desta Solução Educacional"); } //VALIDAR SE O USUARIO POSSUI ACESSO A SE bool usuarioPossuiPermissao = new BMSolucaoEducacional().VerificarSeUsuarioPossuiPermissao(idUsuario, solucaoEducacional.ID); // .ObterListaUsuariosPermitidos(); if (!usuarioPossuiPermissao) { throw new AcademicoException("Erro: O usuário Informado não possui permissão à Solução Educacional"); } //VALIDAR SE O USUARIO ESTA CURSANDO OUTRA SE if (userSelected.ListaMatriculaOferta.Any(y => y.Usuario.ID == userSelected.ID && y.StatusMatricula == enumStatusMatricula.Inscrito)) { throw new AcademicoException("Erro: O usuário já está inscrito em outra oferta."); } //VALIDAR SE O USUARIO ESTA COM ALGUM ABANDONO ATIVO if (new BMUsuarioAbandono().ValidarAbandonoAtivo(idUsuario)) { throw new AcademicoException("Erro: Existe um abandono registrado para este usuário!"); } Oferta oferta = new Oferta(); oferta = solucaoEducacional.ListaOferta.FirstOrDefault(x => x.ID == idOferta); if (oferta == null) { throw new AcademicoException("Erro: Oferta não encontrada"); } //VALIDADO OFERTA CONTINUA. if (oferta.TipoOferta.Equals(enumTipoOferta.Continua)) { Turma t = null; if (oferta.SolucaoEducacional.Fornecedor.PermiteGestaoSGUS) { t = oferta.ListaTurma.FirstOrDefault(x => x.DataFinal == null || x.DataFinal.Value.Date >= DateTime.Now.Date && x.InAberta); } int qtdInscritosNaOferta = oferta.ListaMatriculaOferta.Where(x => (x.StatusMatricula != enumStatusMatricula.CanceladoAdm && x.StatusMatricula != enumStatusMatricula.CanceladoAluno)).Count(); MatriculaOferta matriculaOferta = new MatriculaOferta() { Oferta = new BMOferta().ObterPorId(oferta.ID), Usuario = new BMUsuario().ObterPorId(userSelected.ID), Auditoria = new Auditoria(autenticacao.Login), DataSolicitacao = DateTime.Now, UF = new BMUf().ObterPorId(userSelected.UF.ID), NivelOcupacional = new BMNivelOcupacional().ObterPorID(userSelected.NivelOcupacional.ID) }; if (qtdInscritosNaOferta >= oferta.QuantidadeMaximaInscricoes) { if (oferta.FiladeEspera) { matriculaOferta.StatusMatricula = enumStatusMatricula.FilaEspera; } else { throw new AcademicoException("Erro: A quantidade máxima de alunos foi atingida"); } } else { matriculaOferta.StatusMatricula = enumStatusMatricula.Inscrito; } qtdInscritosNaOferta++; if (t != null) { MatriculaTurma matriculaTurma = new MatriculaTurma() { Turma = new BMTurma().ObterPorID(t.ID), Auditoria = new Auditoria(autenticacao.Login), DataMatricula = DateTime.Now, MatriculaOferta = matriculaOferta, DataLimite = DateTime.Today.AddDays(oferta.DiasPrazo) }; if (matriculaOferta.MatriculaTurma == null) { matriculaOferta.MatriculaTurma = new List <MatriculaTurma>(); } matriculaOferta.MatriculaTurma.Add(matriculaTurma); } moBM.Salvar(matriculaOferta); //validando se a turma já está chegando ao limite. if (qtdInscritosNaOferta > (oferta.QuantidadeMaximaInscricoes - int.Parse(ConfiguracaoSistemaUtil.ObterInformacoes(enumConfiguracaoSistema.LimiteAlertaInscricaoOferta).Registro))) { EnviarEmailLimiteOferta(oferta, matriculaOferta); } ValidarMetaIndividual(idUsuario, idSolucaoEducacional, pListaIdMetaIndividualAssociada, autenticacao); ValidarMetaInstitucional(idUsuario, idSolucaoEducacional, pListaIdMetaInstitucionalAssociada, autenticacao); try { if (matriculaOferta.Oferta.TipoOferta.Equals(enumTipoOferta.Continua) && matriculaOferta.MatriculaTurma != null) { string retornows; switch (matriculaOferta.Oferta.SolucaoEducacional.Fornecedor.ID) { case (int)enumFornecedor.MoodleSebrae: moodle.IntegracaoSoapClient soapCliente = new moodle.IntegracaoSoapClient(); retornows = soapCliente.MatricularAluno(userSelected.Nome, userSelected.CPF, userSelected.Email, userSelected.Cidade, matriculaOferta.Oferta.SolucaoEducacional.IDChaveExterna.ToString(), matriculaOferta.MatriculaTurma.FirstOrDefault().Turma.IDChaveExterna.ToString()); break; case (int)enumFornecedor.WebAula: Turma turma = matriculaOferta.MatriculaTurma.FirstOrDefault().Turma; webaula.waIntegracaoSoapClient wa = new webaula.waIntegracaoSoapClient(); webaula.AuthenticationProviderRequest aut = new webaula.AuthenticationProviderRequest(); webaula.DTOUsuario dtoUsuario = new webaula.DTOUsuario(); webaula.DTOTurma dtoTurma = new webaula.DTOTurma(); dtoTurma.IDChaveExterna = turma.IDChaveExterna; dtoUsuario.CPF = userSelected.CPF; dtoUsuario.Email = userSelected.Email; dtoUsuario.Nome = userSelected.Nome; dtoUsuario.Sexo = userSelected.Sexo; dtoUsuario.UF = userSelected.UF.Sigla; aut.Login = matriculaOferta.Oferta.SolucaoEducacional.Fornecedor.Login; aut.Senha = CriptografiaHelper.Decriptografar(matriculaOferta.Oferta.SolucaoEducacional.Fornecedor.Senha); retornows = wa.Matricular(aut, dtoUsuario, dtoTurma); break; } } } catch (Exception ex) { ErroUtil.Instancia.TratarErro(ex); } return; } //VALIDANDO A OFETA NORMAL if (oferta.TipoOferta.Equals(enumTipoOferta.Normal)) { int qtdInscritosNaOferta = oferta.ListaMatriculaOferta.Where(x => (x.StatusMatricula != enumStatusMatricula.CanceladoAdm && x.StatusMatricula != enumStatusMatricula.CanceladoAluno)).Count(); MatriculaOferta matriculaOferta = new MatriculaOferta() { Oferta = new BMOferta().ObterPorId(oferta.ID), Usuario = new BMUsuario().ObterPorId(userSelected.ID), Auditoria = new Auditoria(autenticacao.Login), DataSolicitacao = DateTime.Now, UF = new BMUf().ObterPorId(userSelected.UF.ID), NivelOcupacional = new BMNivelOcupacional().ObterPorID(userSelected.NivelOcupacional.ID) }; if (qtdInscritosNaOferta >= oferta.QuantidadeMaximaInscricoes) { if (oferta.FiladeEspera) { matriculaOferta.StatusMatricula = enumStatusMatricula.FilaEspera; } else { throw new AcademicoException("Erro: A quantidade máxima de alunos foi atingida"); } } else { matriculaOferta.StatusMatricula = enumStatusMatricula.Inscrito; } BMMatriculaOferta bmMatriculaOferta = new BMMatriculaOferta(); bmMatriculaOferta.Salvar(matriculaOferta); qtdInscritosNaOferta++; //validando se a turma já está chegando ao limite. if (qtdInscritosNaOferta > (oferta.QuantidadeMaximaInscricoes - int.Parse(ConfiguracaoSistemaUtil.ObterInformacoes(enumConfiguracaoSistema.LimiteAlertaInscricaoOferta).Registro))) { EnviarEmailLimiteOferta(oferta, matriculaOferta); } ValidarMetaIndividual(idUsuario, idSolucaoEducacional, pListaIdMetaIndividualAssociada, autenticacao); ValidarMetaInstitucional(idUsuario, idSolucaoEducacional, pListaIdMetaInstitucionalAssociada, autenticacao); return; } throw new Exception("Não foi encontrado ofertas para esse usuário!"); }
public void Add(Oferta Objeto) { _interfaceOferta.Add(Objeto); }
public void editarOferta(Oferta oferta) { RepoOferta.instance().editarOferta(oferta); MessageBox.Show("Oferta Editada"); }
public void Update(Oferta Objeto) { throw new NotImplementedException(); }
public List <ImagenOferta> listarImagenesOfertaPorOferta(Oferta oferta) { return(imagenesOfertaDao.listarImagenesOfertaPorOferta(oferta)); }
public async Task <ActionResult> Put(long id, OfertaViewModel oferta) { if (id != oferta.IdOferta) { return(BadRequest()); } Oferta ofertaBanco = _context.Oferta.Find(id); if (oferta.IdProduto != null) { ofertaBanco.IdProduto = oferta.IdProduto; } if (oferta.IdProduto != null) { ofertaBanco.Titulo = oferta.Titulo; } if (oferta.IdProduto != null) { ofertaBanco.DataOferta = oferta.DataOferta; } if (oferta.IdProduto != null) { ofertaBanco.DataVencimento = oferta.DataVencimento; } if (oferta.Preco != null) { ofertaBanco.Preco = oferta.Preco; } if (oferta.Quantidade != null) { ofertaBanco.Quantidade = oferta.Quantidade; } _context.Entry(ofertaBanco).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { var oferta_valido = await _context.Oferta.FindAsync(id); if (oferta_valido == null) { return(NotFound()); } else { throw; } } return(NoContent()); }
private void lblOfertar_Click(object sender, EventArgs e) { try { if (SessionManager.CurrentRol.Descripcion == "Administrador General") throw new Exception("Siendo un administrador no puede comprar ni ofertar"); List<PublicacionNotCalified> publications = CalificacionPersistance.GetAllPubicacionNotCalified(SessionManager.CurrentUser); if (publications.Count > 5) throw new Exception("Tiene demasiadas compras sin calificar, por favor califíquelas para poder realizar una compra"); //Valido que la oferta sea mayor a la última if (txtMonto.Text == "" || Int32.Parse(txtMonto.Text) <= Int32.Parse(lblPrecio.Text)) throw new Exception("El monto a ofertar debe ser mayor que la oferta actual"); //Creo la nueva oferta y la inserto Oferta newOffer = new Oferta(); newOffer.IdUsuario = SessionManager.CurrentUser.ID; newOffer.IdPublicacion = CurrentPublication.ID; newOffer.Fecha = ConfigurationVariables.FechaSistema; newOffer.Monto = Int32.Parse(txtMonto.Text); newOffer = OfertaPersistance.Insert(newOffer, null); MessageBox.Show("Se insertó la oferta correctamente"); RefreshSources(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public OfertaTrancadaParaPagante() { Oferta = new Oferta(); NivelOcupacional = new NivelOcupacional(); }
public ListadoOferta(Oferta ofertaACargar) { oferta = ofertaACargar; }
int IDAOOferta.Modificar(Entidad e, int idOferta) { Debug.WriteLine("LLEGÓ A MODIFICAROFERTA"); SqlConnection conexion = Connection.getInstance(_connexionString); Oferta oferta = (Oferta)e; Debug.WriteLine("LLEGÓ A MODIFICAROFERTA" + idOferta); Debug.WriteLine("LLEGÓ A MODIFICAROFERTA" + oferta._nombreOferta); try { conexion.Open(); SqlCommand cmd = new SqlCommand("[dbo].[M11_ModificarOferta]", conexion); cmd.CommandType = CommandType.StoredProcedure; Debug.WriteLine("HIZO CONEXIÓN EN VISUAL"); SqlParameter ParId = new SqlParameter(); ParId.ParameterName = "@ofe_id"; ParId.SqlDbType = SqlDbType.Int; ParId.Value = idOferta; cmd.Parameters.Add(ParId); SqlParameter ParNombre = new SqlParameter(); ParNombre.ParameterName = "@ofe_nombre"; ParNombre.SqlDbType = SqlDbType.VarChar; ParNombre.Value = oferta._nombreOferta; cmd.Parameters.Add(ParNombre); SqlParameter ParFechaIni = new SqlParameter(); ParFechaIni.ParameterName = "@ofe_fechaInicio"; ParFechaIni.SqlDbType = SqlDbType.Date; ParFechaIni.Value = oferta._fechaIniOferta.ToString("yyyy-MM-dd"); cmd.Parameters.Add(ParFechaIni); SqlParameter ParFechaFin = new SqlParameter(); ParFechaFin.ParameterName = "@ofe_fechaFin"; ParFechaFin.SqlDbType = SqlDbType.Date; ParFechaFin.Value = oferta._fechaFinOferta.ToString("yyyy-MM-dd"); cmd.Parameters.Add(ParFechaFin); SqlParameter ParPorcentaje = new SqlParameter(); ParPorcentaje.ParameterName = "@ofe_porcentaje"; ParPorcentaje.SqlDbType = SqlDbType.Float; ParPorcentaje.Value = oferta._porcentajeOferta; cmd.Parameters.Add(ParPorcentaje); SqlParameter ParEstado = new SqlParameter(); ParEstado.ParameterName = "@ofe_estado"; ParEstado.SqlDbType = SqlDbType.Bit; if (oferta._estadoOferta == true) { ParEstado.Value = 1; } else { ParEstado.Value = 0; } cmd.Parameters.Add(ParEstado); Debug.WriteLine("HIZO LA PARTED DE PARÁMETRO"); using (SqlDataReader reader = cmd.ExecuteReader()) { cmd.Dispose(); conexion.Close(); return(1); } } catch (SqlException ex) { Debug.WriteLine("Ocurrio un SqlException"); Debug.WriteLine(ex.ToString()); conexion.Close(); return(0); } catch (NullReferenceException ex) { Debug.WriteLine("Ocurrio una NullReferenceException"); Debug.WriteLine(ex.ToString()); conexion.Close(); return(0); } catch (ArgumentNullException ex) { Debug.WriteLine("Ocurrio una ArgumentNullException"); Debug.WriteLine(ex.ToString()); conexion.Close(); return(0); } catch (Exception ex) { Debug.WriteLine("Ocurrio una Exception"); Debug.WriteLine(ex.ToString()); conexion.Close(); return(0); } }
public void Alterar(Oferta oferta) { context.Oferta.Update(oferta); context.SaveChanges(); }
/// <summary> /// Modificar Oferta en la BAse de Datos /// </summary> /// <param name="e">Entidad del tipo oferta</param> /// <returns>1 si agregó y cero si no</returns> int IDAO.Agregar(Entidad e) { Oferta oferta = (Oferta)e; SqlConnection conexion = Connection.getInstance(_connexionString); DateTime dt = new DateTime(2008, 3, 9, 16, 5, 7, 123); Debug.WriteLine("FECHAA" + oferta._fechaIniOferta); string fecha = oferta._fechaIniOferta.ToString("dd-MM-yyyy"); Debug.WriteLine("FECHAA " + fecha); try { conexion.Open(); SqlCommand cmd = new SqlCommand("[dbo].[M11_AgregarOferta]", conexion); cmd.CommandType = CommandType.StoredProcedure; Debug.WriteLine("HIZO CONEXIÓN EN VISUAL"); SqlParameter ParNombre = new SqlParameter(); ParNombre.ParameterName = "@ofe_nombre"; ParNombre.SqlDbType = SqlDbType.VarChar; ParNombre.Value = oferta._nombreOferta; cmd.Parameters.Add(ParNombre); SqlParameter ParFechaIni = new SqlParameter(); ParFechaIni.ParameterName = "@ofe_fechaInicio"; ParFechaIni.SqlDbType = SqlDbType.Date; ParFechaIni.Value = oferta._fechaIniOferta.ToString("yyyy-MM-dd"); cmd.Parameters.Add(ParFechaIni); SqlParameter ParFechaFin = new SqlParameter(); ParFechaFin.ParameterName = "@ofe_fechaFin"; ParFechaFin.SqlDbType = SqlDbType.Date; ParFechaFin.Value = oferta._fechaFinOferta.ToString("yyyy-MM-dd"); cmd.Parameters.Add(ParFechaFin); SqlParameter ParPorcentaje = new SqlParameter(); ParPorcentaje.ParameterName = "@ofe_porcentaje"; ParPorcentaje.SqlDbType = SqlDbType.Float; ParPorcentaje.Value = oferta._porcentajeOferta; cmd.Parameters.Add(ParPorcentaje); SqlParameter ParEstado = new SqlParameter(); ParEstado.ParameterName = "@ofe_estado"; ParEstado.SqlDbType = SqlDbType.Bit; if (oferta._estadoOferta == true) { ParEstado.Value = 1; } else { ParEstado.Value = 0; } cmd.Parameters.Add(ParEstado); Debug.WriteLine("HIZO LA PARTED DE PARÁMETRO"); using (SqlDataReader reader = cmd.ExecuteReader()) { cmd.Dispose(); conexion.Close(); return(1); } } catch (SqlException ex) { Debug.WriteLine("Ocurrio un SqlException"); Debug.WriteLine(ex.ToString()); conexion.Close(); return(2); } catch (NullReferenceException ex) { Debug.WriteLine("Ocurrio una NullReferenceException"); Debug.WriteLine(ex.ToString()); conexion.Close(); return(3); } catch (ArgumentNullException ex) { Debug.WriteLine("Ocurrio una ArgumentNullException"); Debug.WriteLine(ex.ToString()); conexion.Close(); return(4); } catch (Exception ex) { Debug.WriteLine("Ocurrio una Exception"); Debug.WriteLine(ex.ToString()); conexion.Close(); return(5); } }