public ActionResult nuevareserva(reserva1 rec) { if (ModelState.IsValid) { ConectorDataContext db = new ConectorDataContext(); // var vari = from a in db.recervas select a; ViewBag.listarecer=from a in db.recervas select a; var t = db.habitacions.ToList(); ViewBag.habit = t; recerva re = new recerva(); re.idcliente = (from cliid in db.personas where(rec.nombreapellido == (cliid.cliente.nombre+" "+cliid.apellidos).ToString()) select cliid.idcli).First(); re.idhabi= rec.id; string inicio = rec.fechaini.ToString("yyyy-MM-dd"); string final = rec.fechafinal.ToString("yyyy-MM-dd"); re.fechainiciorecer = rec.fechaini; re.fechafinrecer = rec.fechafinal; re.dia=rec.fechafinal.DayOfYear-rec.fechaini.DayOfYear; var idtip= (from pre in db.habitacions where(pre.id==re.idhabi) select pre.idtipo).First(); re.precio = (from prec in db.tipos where (idtip == prec.id) select prec.precio).First().ToString(); /* var t = db.habitacions.ToList(); ViewBag.habit = t; cliente cli = new cliente(); habitacion ha = new habitacion(); int idC = db.habitacions.OrderByDescending(a => a.id).First().id; re.idhabi = idC; re.fechainiciorecer = rec.fechaini; re.fechafinrecer = rec.fechafinal; int d = Convert.ToInt32(re.fechafinrecer.Subtract(re.fechainiciorecer)); re.dia = d; re.precio = rec.precio; */ db.recervas.InsertOnSubmit(re); db.SubmitChanges(); ViewBag.Message = "Datos insertados correctamente"; return View(); //return RedirectToAction("exito", "habitaciones"); } return View(); }
partial void Deleterecerva(recerva instance);
partial void Updaterecerva(recerva instance);
partial void Insertrecerva(recerva instance);
private void detach_recervas(recerva entity) { this.SendPropertyChanging(); entity.habitacion = null; }
private void detach_recervas(recerva entity) { this.SendPropertyChanging(); entity.cliente = null; }
private void attach_recervas(recerva entity) { this.SendPropertyChanging(); entity.cliente = this; }