Esempio n. 1
0
        public dto.ProformaGuardarResponse GuardarProforma(dto.ProformaGuardarRequest r)
        {
            dto.ProformaGuardarResponse response = new dto.ProformaGuardarResponse();
            try
            {
                var detalleEliminar = new dom.ProformaDetalle().Buscar(c => c.ComprobanteId == r.ProformaCabecera.ComprobanteId).ToList();
                foreach (var item in detalleEliminar)
                {
                    new dom.ProformaDetalle().Eliminar(item);
                }

                var cabecera = Mapper.Map <ent.Proforma, dato.Proforma>(r.ProformaCabecera);
                var detalle  = Mapper.Map <IEnumerable <ent.Proformadetalle>, IEnumerable <dato.Proformadetalle> >(r.ProformaDetalle);
                if (r.ProformaCabecera.ComprobanteId != null)
                {
                    cabecera.Id = (int)r.ProformaCabecera.ComprobanteId;
                    new dom.Proforma().Modificar(cabecera);
                }
                else
                {
                    new dom.Proforma().Adicionar(cabecera);
                }

                foreach (var item in detalle)
                {
                    item.ComprobanteId = cabecera.Id;
                    new dom.ProformaDetalle().Adicionar(item);
                }
                response.IdProforma = cabecera.Id;
            }
            catch (Exception Ex)
            {
                response.IdProforma = 0;
            }
            return(response);
        }
Esempio n. 2
0
 public dto.ProformaGuardarResponse GuardarProforma(dto.ProformaGuardarRequest r)
 {
     return(new app.Proforma().GuardarProforma(r));
 }