public PromocionProducto SaveDetalle(PromocionProducto p)
        {
            p = this.db.PromocionProducto.Add(p);

            this.save();

            return(p);
        }
        public PromoDetalle SaveDetalleV2(PromoDetalle p)
        {
            if (p.idPromocion > 0)
            {
                foreach (PromoProductoDetallev1 pp in p.PromoProducto)
                {
                    PromocionProducto _pp = new PromocionProducto();
                    _pp.idProducto  = pp.idProducto;
                    _pp.idPromocion = p.idPromocion;
                    _pp.UsuarioAlta = 1;
                    _pp.FechaAlta   = DateTime.Today;
                    _pp.Estado      = "A";
                    this.db.PromocionProducto.Add(_pp);
                }
                this.save();
            }
            else
            {
                Promocion _p = new Promocion();
                _p.IdPromocion   = 0;
                _p.PrecioContado = p.PrecioContado;
                _p.PrecioTarjeta = p.PrecioTarjeta;
                _p.UsuarioAlta   = p.UsuarioAlta;
                _p.FechaAlta     = p.FechaAlta;
                _p.Descripcion   = p.Descripcion;
                _p.Estado        = "A";
                _p = this.db.Promocion.Add(_p);
                this.save();

                foreach (PromoProductoDetallev1 pp in p.PromoProducto)
                {
                    PromocionProducto _pp = new PromocionProducto();
                    _pp.idProducto  = pp.idProducto;
                    _pp.idPromocion = _p.IdPromocion;
                    _pp.UsuarioAlta = 1;
                    _pp.FechaAlta   = DateTime.Today;
                    _pp.Estado      = "A";
                    this.db.PromocionProducto.Add(_pp);
                    this.save();
                }
            }


            return(p);
        }
        // POST api/<controller>
        public HttpResponseMessage PostDetalle([FromBody] PromocionProducto p)
        {
            HttpResponseMessage response;

            try
            {
                PromocionService service = (PromocionService) new PromocionService().setDatabase(db);
                p.FechaAlta   = DateTime.Today;
                p.UsuarioAlta = 1;
                p.Estado      = "A";
                p             = service.SaveDetalle(p);

                response = this.getSuccessResponse(p);
            }
            catch (Exception e)
            {
                response = this.getErrorResponse(e);
            }
            return(response);
        }
Ejemplo n.º 4
0
 public PromocionDto()
 {
     dtoPromocionProducto = new PromocionProducto();
     dtoPromocionServicio = new PromocionServicio();
 }