예제 #1
0
        public bool Save(Vivero entity)
        {
            Vivero vivero = new Vivero {
                id             = entity.id,
                nombre         = entity.nombre,
                TsEfectiva     = entity.TsEfectiva,
                TsDescontada   = entity.TsDescontada,
                Descuento      = entity.Descuento,
                CostoInicial   = entity.CostoInicial,
                CostoFinal     = entity.CostoFinal,
                ValorNeto      = entity.ValorNeto,
                ValorRecaudado = entity.ValorRecaudado,
                ValorEntero    = entity.ValorEntero,
                TCEA           = entity.TCEA
            };

            try {
                context.Viveros.Add(vivero);
                context.SaveChanges();
            }
            catch (System.Exception) {
                return(false);
            }
            return(true);
        }
예제 #2
0
        public bool Update(Vivero entity)
        {
            try {
                var viveroOriginal = context.Viveros.Single(
                    x => x.id == entity.id
                    );
                viveroOriginal.id             = entity.id;
                viveroOriginal.nombre         = entity.nombre;
                viveroOriginal.TsEfectiva     = entity.TsEfectiva;
                viveroOriginal.TsDescontada   = entity.TsDescontada;
                viveroOriginal.Descuento      = entity.Descuento;
                viveroOriginal.CostoFinal     = entity.CostoFinal;
                viveroOriginal.CostoInicial   = entity.CostoInicial;
                viveroOriginal.ValorEntero    = entity.ValorEntero;
                viveroOriginal.ValorNeto      = entity.ValorNeto;
                viveroOriginal.ValorRecaudado = entity.ValorRecaudado;
                viveroOriginal.TCEA           = entity.TCEA;

                context.Viveros.Update(viveroOriginal);
                context.SaveChanges();
            }
            catch (System.Exception) {
                return(false);
            }
            return(true);
        }
예제 #3
0
        public Vivero FindById(int id)
        {
            var viveros = new Vivero();

            try {
                viveros = context.Viveros.FirstOrDefault(x => x.id == id);
            }
            catch (System.Exception) {
                throw;
            }
            return(viveros);
        }
예제 #4
0
        public bool guardar(ViveroViewModel entity)
        {
            Vivero vivero = new Vivero {
                id             = entity.id,
                nombre         = entity.nombre,
                TsEfectiva     = entity.TsEfectiva,
                TsDescontada   = entity.TsDescontada,
                Descuento      = entity.Descuento,
                CostoInicial   = entity.CostoInicial,
                CostoFinal     = entity.CostoFinal,
                ValorNeto      = entity.ValorNeto,
                ValorRecaudado = entity.ValorRecaudado,
                ValorEntero    = entity.ValorEntero,
                TCEA           = entity.TCEA
            };

            try {
                context.Viveros.Add(vivero);
                context.SaveChanges();
                var plantaActual = new Planta();
                var viveroActual = vivero;

                foreach (var item in entity.plantas)
                {
                    plantaActual = context.Plantas.FirstOrDefault(x => x.id == item.plantaid);
                    Planta_Vivero pv = new Planta_Vivero {
                        vivero = viveroActual,
                        planta = plantaActual,

                        fechaRegistro = item.fechaRegistro
                    };
                    context.Plantas_Viveros.Add(pv);
                }
                context.SaveChanges();
            }
            catch (System.Exception) {
                return(false);
            }
            return(true);
        }
예제 #5
0
 public bool Update(Vivero entity)
 {
     return(viveroRepository.Update(entity));
 }
예제 #6
0
 public bool Save(Vivero entity)
 {
     return(viveroRepository.Save(entity));
 }
예제 #7
0
 public ActionResult Put([FromBody] Vivero vivero)
 {
     return(Ok(
                viveroService.Update(vivero)
                ));
 }