// PUT api/<controller>/5
        //public void Put(int id, [FromBody]string value)
        //{
        //}

        // DELETE api/<controller>/5
        public HttpResponseMessage Delete(long id)
        {
            HttpResponseMessage response;

            try
            {
                PromocionService service = (PromocionService) new PromocionService().setDatabase(db);
                Promocion        p       = service.find(id);
                service.delete(id);

                if (p.Estado == "D")
                {
                    response = this.getSuccessResponse(p);
                }
                else
                {
                    response = this.getSuccessResponse("No se puede eliminar porque existe una compra o hay stock disponible");
                }
            }
            catch (Exception e)
            {
                response = this.getErrorResponse(e);
            }
            return(response);
        }
Exemple #2
0
        public IHttpActionResult PutPromocion(int id, Promocion promocion)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != promocion.promocionid)
            {
                return(BadRequest());
            }

            db.Entry(promocion).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!PromocionExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemple #3
0
        private List <Promocion> dataTableToListServicio()
        {
            List <Promocion> promociones = new List <Promocion>();

            foreach (DataRow dr in promocionesDueno.Rows)
            {
                Promocion promoTemp = new Promocion()
                {
                    idPromocion    = Convert.ToInt32(dr["ID"]),
                    partner        = dr["Partner"].ToString(),
                    mascota        = dr["Pet"].ToString(),
                    descripcion    = dr["Descrip"].ToString(),
                    puntos         = Convert.ToInt32(dr["PointsActive"]),
                    compra         = Convert.ToInt32(dr["UnitsTotal"]),
                    gratis         = Convert.ToInt32(dr["UnitsBought"]),
                    vigencia       = dr["Vigency"].ToString(),
                    esDineroElectr = Convert.ToBoolean(dr["IsPoints"])
                };

                if (!promoTemp.esDineroElectr)
                {
                    promociones.Add(promoTemp);
                }
            }

            return(promociones);
        }
 private Promocion ObtenerDatos()
 {
     try
     {
         Promocion _Datos = new Promocion();
         _Datos.IDPromocion     = NuevoRegistro ? 0 : IDPromocion;
         _Datos.NombrePromocion = this.txtNombrePromocion.Text.Trim();
         _Datos.Lunes           = chkL.Checked;
         _Datos.Martes          = chkM.Checked;
         _Datos.Miercoles       = chkX.Checked;
         _Datos.Jueves          = chkJ.Checked;
         _Datos.Viernes         = chkV.Checked;
         _Datos.Sabado          = chkS.Checked;
         _Datos.Domingo         = chkD.Checked;
         _Datos.TablaSucursales = GenerarTablaSucursales();
         if (NuevoRegistro)
         {
             _Datos.TablaServicios = GenerarTablaServicios();
         }
         return(_Datos);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        public static Promocion getPromocionFromDB(string ruta)
        {
            SqlDataReader reader     = null;
            SqlConnection connection = new SqlConnection();

            connection.ConnectionString = "Data Source=.;Initial Catalog=TECAirlines;Integrated Security=SSPI";

            SqlCommand sqlCmd = new SqlCommand();

            sqlCmd.CommandType = CommandType.Text;

            var query = "SELECT * FROM Promoción WHERE Ruta='@Ruta'";

            query = query.Replace("@Ruta", ruta);

            sqlCmd.CommandText = query;

            sqlCmd.Connection = connection;
            connection.Open();
            reader = sqlCmd.ExecuteReader();
            Promocion promocion = null;

            while (reader.Read())
            {
                promocion = new Promocion();

                promocion.Costo = Convert.ToInt32(reader.GetValue(0));
                promocion.Ruta  = reader.GetValue(1).ToString();
                promocion.Fecha = reader.GetValue(2).ToString();
            }
            connection.Close();
            return(promocion);
        }
        public IHttpActionResult PostPromocion(Promocion promocion)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Promocion.Add(promocion);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (PromocionExists(promocion.id_promocion))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = promocion.id_promocion }, promocion));
        }
        public async Task <bool> UpdatePromotion(Promocion promotion, CancellationToken ct = default(CancellationToken))
        {
            promotion.SetUpdateDate(DateTime.Now);
            await _promocionRepository.UpdateAsync(promotion);

            return(true);
        }
Exemple #8
0
        public async Task <Promocion> Update(string id, Promocion s)
        {
            // Updates and existing supplement.
            await _supplement.ReplaceOneAsync(su => su.Id == id, s);

            return(s);
        }
Exemple #9
0
        public ResponseHelper Guardar(Promocion model)
        {
            ResponseHelper rh = new ResponseHelper();

            try
            {
                using (var ctx = new DataModel())
                {
                    if (model.PromocionId > 0)
                    {
                        ctx.Entry(model).State = System.Data.Entity.EntityState.Modified;
                    }
                    else
                    {
                        ctx.Entry(model).State = System.Data.Entity.EntityState.Added;
                    }
                    ctx.SaveChanges();
                }
            }
            catch (DbEntityValidationException ex)
            {
                EntityValidationExceptionHelper.ProcesarErrores(this, ex);
            }

            return(rh);
        }
 private void btnPrecios_Click(object sender, EventArgs e)
 {
     try
     {
         if (this.dgvPromociones.SelectedRows.Count == 1)
         {
             Promocion Datos = this.ObtenerDatosPromocion();
             this.Visible = false;
             frmPromocionPrecios PreciosPromocion = new frmPromocionPrecios(Datos.IDPromocion);
             PreciosPromocion.ShowDialog();
             PreciosPromocion.Dispose();
             this.Visible = true;
         }
         else
         {
             MessageBox.Show("Seleccione una fila.", Comun.Sistema, MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
     catch (Exception ex)
     {
         LogError.AddExcFileTxt(ex, "frmPromociones ~ btnPrecios_Click");
         MessageBox.Show(Comun.MensajeError, Comun.Sistema, MessageBoxButtons.OK, MessageBoxIcon.Error);
         this.Visible = true;
     }
 }
Exemple #11
0
        public async Task <Promocion> Create(Promocion s)
        {
            //Create a supplement.
            await _supplement.InsertOneAsync(s);

            return(s);
        }
 private void btnEliminar_Click(object sender, EventArgs e)
 {
     try
     {
         if (this.dgvPromociones.SelectedRows.Count == 1)
         {
             Promocion         Datos   = this.ObtenerDatosPromocion();
             Promocion_Negocio PromNeg = new Promocion_Negocio();
             bool Complete             = PromNeg.EliminarPromocion(Comun.Conexion, Datos.IDPromocion, Comun.IDUsuario);
             if (Complete)
             {
                 MessageBox.Show("Registro eliminado.", Comun.Sistema, MessageBoxButtons.OK, MessageBoxIcon.Information);
                 LlenarGrid();
             }
             else
             {
                 MessageBox.Show("Ocurrió un error al eliminar el registro.", Comun.Sistema, MessageBoxButtons.OK, MessageBoxIcon.Warning);
             }
         }
         else
         {
             MessageBox.Show("Seleccione una fila.", Comun.Sistema, MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
     catch (Exception ex)
     {
         LogError.AddExcFileTxt(ex, "frmPromociones ~ btnImpresion_Click");
         MessageBox.Show(Comun.MensajeError, Comun.Sistema, MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
        public List <Promocion> Promociones()
        {
            SqlConnection conexion = new SqlConnection(WebConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString);

            conexion.Open();
            string           sql              = "select * from Promociones";
            SqlDataAdapter   adp              = new SqlDataAdapter(sql, conexion);
            DataSet          datos            = new DataSet();
            List <Promocion> listaPromociones = new List <Promocion>();

            adp.Fill(datos, "Promocion");
            foreach (DataRow row in datos.Tables[0].Rows)
            {
                var newPromocion = new Promocion()
                {
                    idPromocion      = Int32.Parse(row[0].ToString()),
                    Descuento        = Int32.Parse(row[1].ToString()),
                    Tandas_idTanda   = Int32.Parse(row[2].ToString()),
                    PuntosRequeridos = Int32.Parse(row[3].ToString()),
                    Nombre           = row[4].ToString(),
                    Descripcion      = row[5].ToString(),
                    Imagen           = row[6].ToString(),
                };
                listaPromociones.Add(newPromocion);
            }
            conexion.Close();
            return(listaPromociones);
        }
        public void Modificar(Promocion promocion)
        {
            //Creamos el objeto que se conecta con la base de datos
            //Es necesario enciarle la cadena de conexion para que
            //conozca cual es la base de datos
            SqlConnection conexion = new SqlConnection(Conexion.Cadena);

            try
            {
                // Se debe abrir la conexión
                conexion.Open();
                //Sentencia que se necesita ejecutar
                string sql = "PA_Modificar_Promocion";
                //El comando es el objeto que ejecuta la sebntencia
                SqlCommand comando = new SqlCommand(sql, conexion);
                // Nota: es obligatorio cambiar el tipo de comando
                comando.CommandType = System.Data.CommandType.StoredProcedure;
                comando.Parameters.AddWithValue("@idPromocion", promocion.idPromocion);
                comando.Parameters.AddWithValue("@porcentajeDescuento", promocion.porcentajeDescuento);
                comando.Parameters.AddWithValue("@estado", promocion.estado);

                // Ejecutar el comando
                comando.ExecuteNonQuery();
            }
            catch (Exception)
            {
                throw;
            }

            finally
            {
                conexion.Close();
            }
        }
Exemple #15
0
        public async Task <IActionResult> EditarPromociones(Promocion p, ICollection <IFormFile> files)
        {
            if (p.Id == 0)
            {
                return(NotFound());
            }

            var upload = Path.Combine(_environment.WebRootPath, "images");

            foreach (var file in files)
            {
                if (file.Length > 0)
                {
                    using (var fileStream = new FileStream(Path.Combine(upload, file.FileName), FileMode.Create))
                    {
                        p.RutaImage = "/images/" + file.FileName;
                        await file.CopyToAsync(fileStream);
                    }
                }
            }

            if (ModelState.IsValid)
            {
                try{
                    _contexto.Update(p);
                    await _contexto.SaveChangesAsync();
                }catch (Exception e)
                {
                    return(RedirectToAction("Index"));
                }
            }
            return(View(p));
        }
Exemple #16
0
        internal void Update(Promocion parent)
        {
            // if we're not dirty then don't update the database
            if (!this.IsDirty)
            {
                return;
            }

            OidPromocion = parent.Oid;

            try
            {
                ValidationRules.CheckRules();

                if (!IsValid)
                {
                    throw new iQValidationException(moleQule.Library.Resources.Messages.GENERIC_VALIDATION_ERROR);
                }

                AlumnoPromocionRecord obj = parent.Session().Get <AlumnoPromocionRecord>(Oid);
                obj.CopyValues(this.Base.Record);
                parent.Session().Update(obj);
            }
            catch (Exception ex)
            {
                iQExceptionHandler.TreatException(ex);
            }

            MarkOld();
        }
        public List <Promocion> SeleccionarTodosPromocion(int estado)
        {
            List <Promocion> lista = new List <Promocion>();
            //Creamos el objeto que se conecta con la base de datos
            //Es necesario enciarle la cadena de conexion para que
            //conozca cual es la base de datos
            SqlConnection conexion = new SqlConnection(Conexion.Cadena);

            try
            {
                // Se debe abrir la conexión
                conexion.Open();
                //Sentencia que se necesita ejecutar
                string sql = "PA_Seleccionar_Promocion_2";
                //El comando es el objeto que ejecuta la sentencia
                SqlCommand comando = new SqlCommand(sql, conexion);
                // Nota: es obligatorio cambiar el tipo de comando
                comando.CommandType = System.Data.CommandType.StoredProcedure;
                comando.Parameters.AddWithValue("@estado", estado);


                // Ejecutar el comando de modo que retorne datos
                SqlDataReader reader = comando.ExecuteReader();



                //lee todas las filas resultado de la consulta
                while (reader.Read())
                {
                    // Se extrae la informacion de la tupla y se convierte a un objeto
                    Promocion promocion = new Promocion();
                    promocion.idPromocion         = Convert.ToInt32(reader["Id"].ToString());
                    promocion.idProducto          = reader["IdProducto"].ToString();
                    promocion.nombreProducto      = reader["NombreProducto"].ToString();
                    promocion.porcentajeDescuento = Convert.ToDouble(reader["PorcentajeDescuento"].ToString());
                    promocion.estado = Convert.ToInt32(reader["Estado"].ToString());
                    if (promocion.estado == 1)
                    {
                        promocion.nombreEstado = "Activo";
                    }
                    else
                    {
                        promocion.nombreEstado = "Inactivo";
                    }

                    lista.Add(promocion);
                }

                return(lista);
            }
            catch (Exception)
            {
                throw;
            }

            finally
            {
                conexion.Close();
            }
        }
Exemple #18
0
        internal void DeleteSelf(Promocion parent)
        {
            // if we're not dirty then don't update the database
            if (!this.IsDirty)
            {
                return;
            }

            // if we're new then don't update the database
            if (this.IsNew)
            {
                return;
            }

            try
            {
                parent.Session().Delete(parent.Session().Get <AlumnoPromocionRecord>(Oid));
            }
            catch (Exception ex)
            {
                iQExceptionHandler.TreatException(ex);
            }

            MarkNew();
        }
        public async Task <bool> InsertPromotion(Promocion promotion)
        {
            promotion.SetCreationDate();
            await _promocionRepository.InsertAsync(promotion);

            return(true);
        }
Exemple #20
0
        private ObservableCollection <Promocion> dataTableToListProductos(string texto)
        {
            if (!CrossConnectivity.Current.IsConnected)
            {
                DisplayAlert("Error", "No estás conectado a internet", "Ok");
                return(null);
            }

            ObservableCollection <Promocion> promociones = new ObservableCollection <Promocion>();

            foreach (DataRow dr in promoProductosVet.Rows)
            {
                Promocion promoTemp = new Promocion()
                {
                    nombre   = dr["Name"].ToString(),
                    inicia   = dr["StartDate"].ToString(),
                    vigencia = dr["EndDate"].ToString(),
                    tipo     = dr["ProductType"].ToString(),
                    marca    = dr["Brand"].ToString(),
                    producto = dr["Product"].ToString(),
                    precio   = Convert.ToDouble(dr["RegularPrice"]),
                    puntos   = Convert.ToDouble(dr["Points"]),
                    UPC      = dr["UPC"].ToString()
                };

                if (promoTemp.nombre.ToUpper().Contains(texto.ToUpper()))
                {
                    promociones.Add(promoTemp);
                }
            }
            return(promociones);
        }
Exemple #21
0
 public List <Promocion> ObtenerPromociones(string Conexion, string Busqueda)
 {
     try
     {
         List <Promocion> Lista = new List <Promocion>();
         Promocion        Item;
         SqlDataReader    Dr = SqlHelper.ExecuteReader(Conexion, "Produccion.spCSLDB_get_Promociones", Busqueda);
         while (Dr.Read())
         {
             Item                 = new Promocion();
             Item.IDPromocion     = !Dr.IsDBNull(Dr.GetOrdinal("IDPromocion")) ? Dr.GetInt32(Dr.GetOrdinal("IDPromocion")) : 0;
             Item.NombrePromocion = !Dr.IsDBNull(Dr.GetOrdinal("NombrePromocion")) ? Dr.GetString(Dr.GetOrdinal("NombrePromocion")) : string.Empty;
             Item.IDEstatus       = !Dr.IsDBNull(Dr.GetOrdinal("IDEstatus")) ? Dr.GetInt32(Dr.GetOrdinal("IDEstatus")) : 0;
             Item.Estatus         = !Dr.IsDBNull(Dr.GetOrdinal("Estatus")) ? Dr.GetString(Dr.GetOrdinal("Estatus")) : string.Empty;
             Item.Dias            = !Dr.IsDBNull(Dr.GetOrdinal("DiasSemana")) ? Dr.GetString(Dr.GetOrdinal("DiasSemana")) : string.Empty;
             Item.Sucursales      = !Dr.IsDBNull(Dr.GetOrdinal("Sucursales")) ? Dr.GetString(Dr.GetOrdinal("Sucursales")) : string.Empty;
             Lista.Add(Item);
         }
         Dr.Close();
         return(Lista);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemple #22
0
        private string convertUPCtoName(string UPC)
        {
            foreach (DataRow dr in promoProductosVet.Rows)
            {
                Promocion promoTemp = new Promocion()
                {
                    nombre   = dr["Name"].ToString(),
                    inicia   = dr["StartDate"].ToString(),
                    vigencia = dr["EndDate"].ToString(),
                    tipo     = dr["ProductType"].ToString(),
                    marca    = dr["Brand"].ToString(),
                    producto = dr["Product"].ToString(),
                    precio   = Convert.ToDouble(dr["RegularPrice"]),
                    puntos   = Convert.ToDouble(dr["Points"]),
                    UPC      = dr["UPC"].ToString()
                };

                if (promoTemp.UPC == UPC)
                {
                    return(promoTemp.nombre);
                }
            }

            return("");
        }
        public static bool addPromocionToDB(Promocion promocion)
        {
            var connectionString = "Data Source=.;Initial Catalog=TECAirlines;Integrated Security=SSPI";

            var query = "INSERT INTO Promoción (Costo, Ruta, Fecha) " +
                        "VALUES ('@Costo', '@Ruta', '@Fecha')";


            query = query.Replace("@Costo", promocion.Costo.ToString())
                    .Replace("@Ruta", promocion.Ruta)
                    .Replace("@Fecha", promocion.Fecha.ToString());


            SqlConnection connection = new SqlConnection(connectionString);

            try
            {
                connection.Open();
                SqlCommand command = new SqlCommand(query, connection);
                command.ExecuteNonQuery();
                command.Dispose();
                connection.Close();
                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
Exemple #24
0
        private ObservableCollection <Promocion> dataTableToListServicios(string texto)
        {
            if (!CrossConnectivity.Current.IsConnected)
            {
                DisplayAlert("Error", "No estás conectado a internet", "Ok");
                return(null);
            }

            ObservableCollection <Promocion> promociones = new ObservableCollection <Promocion>();

            foreach (DataRow dr in promoServiciosVet.Rows)
            {
                Promocion promoTemp = new Promocion()
                {
                    nombre       = dr["Name"].ToString(),
                    inicia       = dr["StartDate"].ToString(),
                    vigencia     = dr["EndDate"].ToString(),
                    tipo         = dr["PetType"].ToString(),
                    producto     = dr["ServiceType"].ToString(),
                    precio       = Convert.ToDouble(dr["RegularPrice"]),
                    compra       = Convert.ToInt32(dr["Units"]),
                    PartnerPrice = Convert.ToDouble(dr["PartnerPrice"])
                };

                if (promoTemp.nombre.ToUpper().Contains(texto.ToUpper()))
                {
                    listaServicios.Add(promoTemp);
                    promociones.Add(promoTemp);
                }
            }

            return(promociones);
        }
        public static List <Promocion> getAllPromocionesFromDB()
        {
            SqlDataReader reader     = null;
            SqlConnection connection = new SqlConnection();

            connection.ConnectionString = "Data Source=.;Initial Catalog=TECAirlines;Integrated Security=SSPI";

            SqlCommand sqlCmd = new SqlCommand();

            sqlCmd.CommandType = CommandType.Text;

            var query = "SELECT * FROM Promoción ";



            sqlCmd.CommandText = query;

            sqlCmd.Connection = connection;
            connection.Open();
            reader = sqlCmd.ExecuteReader();
            List <Promocion> listaPromociones = new List <Promocion>();

            while (reader.Read())
            {
                Promocion promocion = null;
                promocion       = new Promocion();
                promocion.Costo = Convert.ToInt32(reader.GetValue(0));
                promocion.Ruta  = reader.GetValue(1).ToString();
                promocion.Fecha = reader.GetValue(2).ToString();

                listaPromociones.Add(promocion);
            }
            connection.Close();
            return(listaPromociones);
        }
Exemple #26
0
        public void ServicioSelectedDelete(object sender, EventArgs args)
        {
            if (!CrossConnectivity.Current.IsConnected)
            {
                DisplayAlert("Error", "No estás conectado a internet", "Ok");
                return;
            }
            Button button = (Button)sender;
            //int idPromocion = Convert.ToInt32(button.CommandParameter);
            Promocion promocion = button.CommandParameter as Promocion;

            Device.BeginInvokeOnMainThread(async() => {
                var result = await this.DisplayAlert("Eliminar", "¿Eliminar promoción?", "Si", "No");
                if (result)
                {
                    Retorno status = DependencyService.Get <IWebService>().promoServicio_Eliminar(promocion.idPromocion);
                    if (status.Resultado)
                    {
                        lsvServicios.IsRefreshing = true;
                        listaServiciosCompleto.Clear();
                        ListaServicios.Clear();
                        promoServiciosVet.Clear();
                        promoServiciosVet         = DependencyService.Get <IWebService>().getPromoServicios_Busca(Preferences.Get("idAsociado", -1));
                        listaServiciosCompleto    = dataTableToListServicios();
                        lsvServicios.ItemsSource  = listaServicios;
                        lsvServicios.IsRefreshing = false;
                        await DisplayAlert("Eliminado", "Se elimino correctamente", "Ok");
                    }
                    else
                    {
                        await DisplayAlert("Error", status.Mensaje, "OK");
                    }
                }
            });
        }
Exemple #27
0
        private void dataTableToListServicios(int idAsociado)
        {
            if (!CrossConnectivity.Current.IsConnected)
            {
                DisplayAlert("Error", "No estás conectado a internet", "Ok");
                return;
            }

            promoServiciosVet = DependencyService.Get <IWebService>().getPromoServicios_Busca(idAsociado);

            foreach (DataRow dr in promoServiciosVet.Rows)
            {
                Promocion promoTemp = new Promocion()
                {
                    idPromocion  = Convert.ToInt32(dr["IDPartnerService"].ToString()),
                    nombre       = dr["Name"].ToString(),
                    inicia       = dr["StartDate"].ToString(),
                    vigencia     = dr["EndDate"].ToString(),
                    isProduct    = false,
                    isService    = true,
                    tipo         = dr["PetType"].ToString(),
                    producto     = dr["ServiceType"].ToString(),
                    precio       = Convert.ToDouble(dr["RegularPrice"]),
                    compra       = Convert.ToInt32(dr["Units"]),
                    PartnerPrice = Convert.ToDouble(dr["PartnerPrice"]),
                    partner      = dr["Partner"].ToString()
                };
                //listaServicios.Add(promoTemp);
                promociones.Add(promoTemp);
            }

            //return promociones;
        }
        private void ShowEnteComercials(object obj)
        {
            var result = (from q in _enteComercialRepository.GetPromocionesVigentes() select q).ToList();

            EnteComercial0 = result.ElementAtOrDefault <Promocion>(0) ?? new Promocion()
            {
                EnteComercial = new EnteComercial()
                {
                    Nombre = "Disponible"
                }
            };
            EnteComercial1 = result.ElementAtOrDefault <Promocion>(1) ?? new Promocion()
            {
                EnteComercial = new EnteComercial()
                {
                    Nombre = "Disponible"
                }
            };
            EnteComercial2 = result.ElementAtOrDefault <Promocion>(2) ?? new Promocion()
            {
                EnteComercial = new EnteComercial()
                {
                    Nombre = "Disponible"
                }
            };

            this.OnPropertyChanged(() => this.EnteComercial0);
            this.OnPropertyChanged(() => this.EnteComercial1);
            this.OnPropertyChanged(() => this.EnteComercial2);
        }
Exemple #29
0
        public async Task DeleteCupon()
        {
            //Arrange

            var BDName  = Guid.NewGuid().ToString();
            var context = BuildContext(BDName);

            var fakecupon = new Promocion()
            {
                Nombre      = "Revifast promo",
                Descuento   = 1,
                Descripcion = "Registrarse en la app",
                ServicioId  = 1,
            };

            context.Promociones.Add(fakecupon);
            await context.SaveChangesAsync();

            var context2 = BuildContext(BDName);

            //Act
            var controller = new PromocionesController(context2);

            var response = await controller.Delete(1);

            var cancel = response as StatusCodeResult;

            //Assert
            Assert.AreEqual(200, cancel.StatusCode);

            var context3 = BuildContext(BDName);
            var exist    = await context3.Promociones.FindAsync(1);

            Assert.IsNull(exist);
        }
Exemple #30
0
 public void UpdatePromocion(Promocion item)
 {
     try
     {
         using (db = new Entities())
         {
             Promocion oPromocion = db.Promocion.Where(x => x.PromocionID == item.PromocionID).FirstOrDefault();
             if (oPromocion != null)
             {
                 oPromocion.Nombre          = item.Nombre;
                 oPromocion.Descripcion     = item.Descripcion;
                 oPromocion.FechaInicio     = item.FechaInicio;
                 oPromocion.FechaFin        = item.FechaFin;
                 oPromocion.ProductoID      = item.ProductoID;
                 oPromocion.PrecioPromocion = item.PrecioPromocion;
                 oPromocion.Imagen          = item.Imagen;
                 db.SaveChanges();
             }
         }
     }
     catch (Exception ex)
     {
         throw new Exception(SrvMessages.getMessageSQL(ex));
     }
 }
 public void insertar(Promocion objPromocion)
 {
     using (var context = new FideCineEntities())
     {
         context.Promocion.AddObject(objPromocion);
         context.SaveChanges();
     }
 }
        public ActionResult Create(Promocion promocion)
        {
            if (ModelState.IsValid)
            {
                db.Promocion.Add(promocion);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(promocion);
        }
        public ResultadoBE insertar(PromocionBE objPromocionBE)
        {
            Promocion objPromocion = new Promocion();
            objPromocion.IdProducto = objPromocionBE.IdProducto;
            objPromocion.Puntos = objPromocionBE.Puntos;
            objPromocion.vigenciaInicio = DateTime.ParseExact(objPromocionBE.VigenciaInicio, "dd/MM/yyyy", CultureInfo.InvariantCulture);
            objPromocion.vigenciaFin = DateTime.ParseExact(objPromocionBE.VigenciaFin, "dd/MM/yyyy", CultureInfo.InvariantCulture);

            string rutaColaOut = @".\private$\fidecine_promocion";
            if (!MessageQueue.Exists(rutaColaOut))
                MessageQueue.Create(rutaColaOut);
            MessageQueue colaOut = new MessageQueue(rutaColaOut);
            Message mensajeOut = new Message();
            mensajeOut.Label = "Nueva Prmocion";
            mensajeOut.Body = objPromocion;
            colaOut.Send(mensajeOut);

            return new ResultadoBE() { Mensaje = "La Oferta ingresada fue registrada con éxito" };
        }
 public ActionResult Edit(Promocion promocion)
 {
     if (ModelState.IsValid)
     {
         db.Entry(promocion).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     return View(promocion);
 }