Ejemplo n.º 1
0
 public void MudarCuentas(ICollection <Cuentas> cuentas)
 {
     foreach (var item in cuentas)
     {
         var cuentasHistory = new CuentasHistory();
         cuentasHistory.AIdentificador = item.AptsIdentificador;
         cuentasHistory.Tipo           = item.Tipo;
         cuentasHistory.Monto          = item.Monto;
         cuentasHistory.fecha          = item.fecha;
         db.CuentasHistory.Add(cuentasHistory);
     }
 }
Ejemplo n.º 2
0
        public async Task <ActionResult> Delete(int?id, string fecha)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            else
            {
                var apt = await db.Apt.FindAsync(id.ToString());

                var conta      = new CuentasHistory();
                var aptHistory = new AlugueHistory
                {
                    AIdentificador = apt.AptsIdentificador,
                    Descripcion    = apt.Descripcion,
                    Precio         = apt.Precio,
                    PersonaID      = apt.PersonaID,
                    FechaInicio    = apt.FechaInicio,
                    FechaSalida    = fecha,
                    Foto1          = apt.Foto1,
                    Foto2          = apt.Foto2,
                    Foto3          = apt.Foto3,
                    Persona        = apt.Persona,
                };

                db.AlugueHistory.Add(aptHistory);
                MudarCuentas(apt.Cuentas);
                db.Cuentas.RemoveRange(apt.Cuentas);
                var aptSolo = await db.AptSolo.FindAsync(int.Parse(apt.AptsIdentificador));

                aptSolo.Alugado         = false;
                db.Entry(aptSolo).State = EntityState.Modified;
                db.Apt.Remove(apt);

                await db.SaveChangesAsync();

                return(RedirectToAction("Index1"));
            }
        }