public async Task Update(Logement entity) { var Logement = await dbContext.Logements.FindAsync(entity.LogementId); dbContext.Entry(Logement).State = EntityState.Detached; dbContext.Entry(entity).State = EntityState.Modified; try { await dbContext.SaveChangesAsync(); } catch (Exception) { throw new NotImplementedException(); } }
public void update(Logement logementParam) { var logement = _context.Logements.Find(logementParam.id); if (logement == null) { throw new AppException("Logement not found"); } // update user properties _context.Logements.Update(logement); _context.SaveChanges(); }
public async Task <IActionResult> CreateLogement(LogementViewmodel model, int id) { ViewData["Id"] = id; Experience experience = await ExperienceService.GetById(id); if (ModelState.IsValid) { string uniqueFileName = null; if (model.FileP != null) { string uploadsFolder = Path.Combine(hostingEnvironment.WebRootPath, "Files"); uniqueFileName = Guid.NewGuid().ToString() + "_" + model.FileP.FileName; string filePath = Path.Combine(uploadsFolder, uniqueFileName); model.FileP.CopyTo(new FileStream(filePath, FileMode.Create)); } Logement logement = new Logement { Datedebut = model.Datedebut, DateFin = model.DateFin, Lieu = model.Lieu, Image = uniqueFileName, NbJours = model.NbJours, Prix = model.Prix, Type = model.Type, ExperienceId = id }; experience.Logement = logement; await ExperienceService.PutExperienceAsync(id, experience); await LogementService.Ajout(logement); TempData["expID"] = JsonConvert.SerializeObject(experience.ExperienceId); return(RedirectToAction("CreateNourriture")); } return(View(model)); }
/** * Redirige vers la page de Détail de logement * où on peut créer une réservation */ // GET: ReservationsController/Create public ActionResult Create(int id) { Logement logement = getLogement(id); var reservationVM = new ReservationModelView { IdLogement = logement.Id, DateDebut = DateTime.Now, DateFin = DateTime.Now.AddDays(7) }; List <Reservation> reservations = getAllReservationsByLogement(logement.Id); ViewData["reservations"] = Newtonsoft.Json.JsonConvert.SerializeObject(reservations); ViewData["logement"] = logement; return(View(reservationVM)); }
public async Task <IActionResult> Create([Bind("LogementId,adresse,Ville,TypeEnergie,surface,ClientId")] Logement logement) { if (ModelState.IsValid) { var user_ = await _userManager.FindByEmailAsync(User.Identity.Name); var ClientId = (from C in _context.Clients where C.email == user_.Email select C.ClientId).FirstOrDefault(); logement.ClientId = ClientId; _context.Add(logement); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } // ViewData["ClientId"] = new SelectList(_context.Clients, "ClientId", "email", logement.ClientId); return(View(logement)); }
public ActionResult Create(FormCollection formcollection) { try { Logement logement = new Logement(); logement.LibreOccupe = bool.Parse(formcollection["LibreOccupe"]); logement.Pieces = int.Parse(formcollection["Pieces"]); logement.Surface = formcollection["Surface"]; logement.Id = int.Parse(formcollection["Id"]); return(View("Index")); } catch { return(View(dal.GetLogement())); } }
public async Task <IActionResult> UpdateLogement(int id, Logement model, IFormFile FileP) { if (ModelState.IsValid) { string uniqueFileName = null; if (FileP != null) { string uploadsFolder = Path.Combine(hostingEnvironment.WebRootPath, "Files"); uniqueFileName = Guid.NewGuid().ToString() + "_" + FileP.FileName; string filePath = Path.Combine(uploadsFolder, uniqueFileName); FileP.CopyTo(new FileStream(filePath, FileMode.Create)); } Logement l = LogementService.GetLogement(id); System.Diagnostics.Debug.WriteLine(" l'id du logement est " + l.LogementId); l.ExperienceId = id; l.Datedebut = model.Datedebut; l.DateFin = model.DateFin; l.Lieu = model.Lieu; l.NbJours = model.NbJours; l.Prix = model.Prix; l.Type = model.Type; if (uniqueFileName != null) { l.Image = uniqueFileName; } await LogementService.Update(l); return(RedirectToAction("MesExperiences")); } return(View(model)); }
public void desaffecterUnLogementDunParc(Logement logement, Parc parc) { parc.supprimeLogement(logement); }
public void affecterLogementAParc(Logement logement, Parc parc) { parc.ajouterLogement(logement); }
public bool affecterLocataireALogement(Locataire locataire, Logement logement) { return(logement.setLocataire(locataire)); }
public void supprimerLogement(Logement logement) { this.listeDeLogements.Remove(logement); logementDao.delete(logement.getid()); listeDeLogements = logementDao.selectTout(); }
public ActionResult Create(ReservationModelView reservationVM) { // récupère l'utilisateur authentifié Utilisateur utilisateur = null; if (HttpContext.Session.GetInt32("userId") != null && HttpContext.Session.GetInt32("userId") > 0) { int idUtilisateur = (int)HttpContext.Session.GetInt32("userId"); //Convert.ToInt32(HttpContext.Request.Cookies["userId"]); utilisateur = _db.Utilisateurs.Single(utilisateur => utilisateur.Id == idUtilisateur); } if (utilisateur == null) { TempData["messageErreur"] = "Connectez-vous pour effectuer une réservation"; return(RedirectToAction("Index", "Home")); } Logement logement = getLogement(reservationVM.IdLogement); List <Reservation> reservations = getAllReservationsByLogement(logement.Id); ViewData["reservations"] = Newtonsoft.Json.JsonConvert.SerializeObject(reservations); ViewData["logement"] = logement; foreach (Reservation reservation in reservations) { bool overlap = isPeriodeDisponible(reservation.DateDebut, reservation.DateFin, reservationVM.DateDebut, reservationVM.DateFin); if (overlap) { ModelState.AddModelError("", "La réservation n'est pas disponible pour la période choisie!"); return(View(reservationVM)); } } if (!ModelState.IsValid) { return(View(reservationVM)); } if (!reservationVM.Validated) { var validationResults = reservationVM.Validate(new ValidationContext(reservationVM, null, null)); foreach (var error in validationResults) { foreach (var memberName in error.MemberNames) { ModelState.AddModelError(memberName, error.ErrorMessage); } } return(View(reservationVM)); } try { Reservation reservation = new Reservation() { Logement = logement, DateDebut = reservationVM.DateDebut, DateFin = reservationVM.DateFin, Locateur = utilisateur }; _db.Reservations.Add(reservation); _db.SaveChanges(); TempData["messageSucces"] = "Réservation effectuée avec succès !"; return(RedirectToAction("Details", new { id = reservation.Id })); } catch { return(View(reservationVM)); } }
public Task Update(Logement entity) { return(LogementRepo.Update(entity)); }
public async Task <Logement> GetLogementById(int id) { Logement a = await GenericRepo.GetByIdAsync(id); return(a); }
public Task Ajout(Logement entity) { return(GenericRepo.InsertAsync(entity)); }
public static void LoadGame(string saveKey) { Ville v; JObject vJObject; try { StreamReader stm = new StreamReader(folder + saveKey + ".txt"); string jsonString = stm.ReadToEnd(); vJObject = JObject.Parse(jsonString); v = JsonConvert.DeserializeObject <Ville>(jsonString); } catch (Exception e) { UnityEngine.Object.FindObjectOfType <LogBox>().WriteLog(e.Message); return; } v.LoadData(); List <Amenagement> newAmenagements = new List <Amenagement>(); JArray amenagements = (JArray)vJObject["Amenagements"]; for (int i = 0; i < amenagements.Count; i++) { JToken a = amenagements[i]; string type = a["Type"].ToString(); if (type == "Route") { Route r = new Route(a["Nom"].ToString(), Int32.Parse(a["Prix"].ToString()), Int32.Parse(a["Taille"].ToString()), Int32.Parse(a["PosX"].ToString()), Int32.Parse(a["PosY"].ToString()), bool.Parse(a["EstSortie"].ToString())); r.Rotation = new Vector3(float.Parse(a["Rotation"]["x"].ToString()), float.Parse(a["Rotation"]["y"].ToString()), float.Parse(a["Rotation"]["z"].ToString())); newAmenagements.Add(r); } /* if (type == "Batiment") * { * Batiment b = new Batiment(a["Nom"].ToString(), Int32.Parse(a["Prix"].ToString()), Int32.Parse(a["Taille"].ToString()), Int32.Parse(a["PosX"].ToString()), Int32.Parse(a["PosY"].ToString()), bool.Parse(a["EstSortie"].ToString())); * b.Rotation = new Vector3(float.Parse(a["Rotation"]["x"].ToString()), float.Parse(a["Rotation"]["y"].ToString()), float.Parse(a["Rotation"]["z"].ToString())); * newAmenagements.Add(b); * } */ if (type == "BatimentAdministratif") { BatimentAdministratif t = new BatimentAdministratif(Int32.Parse(a["NombreHabitantNecessaire"].ToString()), Int32.Parse(a["CoutMensuel"].ToString()), a["Nom"].ToString(), Int32.Parse(a["Prix"].ToString()), Int32.Parse(a["Taille"].ToString()), Int32.Parse(a["Niveau"].ToString())); t.Rotation = new Vector3(float.Parse(a["Rotation"]["x"].ToString()), float.Parse(a["Rotation"]["y"].ToString()), float.Parse(a["Rotation"]["z"].ToString())); t.PosX = Int32.Parse(a["PosX"].ToString()); t.PosY = Int32.Parse(a["PosY"].ToString()); newAmenagements.Add(t); } if (type == "Bureau") { Bureau t = new Bureau(Int32.Parse(a["MaxPlaceDispo"].ToString()), float.Parse(a["PrixLocation"].ToString()), Int32.Parse(a["CoutMensuel"].ToString()), a["Nom"].ToString(), Int32.Parse(a["Prix"].ToString()), Int32.Parse(a["Taille"].ToString()), Int32.Parse(a["Niveau"].ToString())); t.Rotation = new Vector3(float.Parse(a["Rotation"]["x"].ToString()), float.Parse(a["Rotation"]["y"].ToString()), float.Parse(a["Rotation"]["z"].ToString())); t.PosX = Int32.Parse(a["PosX"].ToString()); t.PosY = Int32.Parse(a["PosY"].ToString()); newAmenagements.Add(t); } if (type == "Commercant") { Commercant t = new Commercant(Int32.Parse(a["NbrEmployeMaxAise"].ToString()), Int32.Parse(a["NbrEmployeMaxMoyenne"].ToString()), Int32.Parse(a["NbrEmployeMaxOuvriere"].ToString()), Int32.Parse(a["CoutMensuel"].ToString()), a["Nom"].ToString(), Int32.Parse(a["Prix"].ToString()), Int32.Parse(a["Taille"].ToString()), Int32.Parse(a["Niveau"].ToString())); t.Rotation = new Vector3(float.Parse(a["Rotation"]["x"].ToString()), float.Parse(a["Rotation"]["y"].ToString()), float.Parse(a["Rotation"]["z"].ToString())); t.PosX = Int32.Parse(a["PosX"].ToString()); t.PosY = Int32.Parse(a["PosY"].ToString()); newAmenagements.Add(t); } if (type == "CompagnieEau") { CompagnieEau t = new CompagnieEau(Int32.Parse(a["ProductionMax"].ToString()), Int32.Parse(a["NbrEmployeMaxAise"].ToString()), Int32.Parse(a["NbrEmployeMaxMoyenne"].ToString()), Int32.Parse(a["NbrEmployeMaxOuvriere"].ToString()), Int32.Parse(a["CoutMensuel"].ToString()), a["Nom"].ToString(), Int32.Parse(a["Prix"].ToString()), Int32.Parse(a["Taille"].ToString()), Int32.Parse(a["Niveau"].ToString())); t.Rotation = new Vector3(float.Parse(a["Rotation"]["x"].ToString()), float.Parse(a["Rotation"]["y"].ToString()), float.Parse(a["Rotation"]["z"].ToString())); t.PosX = Int32.Parse(a["PosX"].ToString()); t.PosY = Int32.Parse(a["PosY"].ToString()); newAmenagements.Add(t); } if (type == "CompagnieElectricite") { CompagnieElectricite t = new CompagnieElectricite(Int32.Parse(a["ProductionMax"].ToString()), Int32.Parse(a["NbrEmployeMaxAise"].ToString()), Int32.Parse(a["NbrEmployeMaxMoyenne"].ToString()), Int32.Parse(a["NbrEmployeMaxOuvriere"].ToString()), Int32.Parse(a["CoutMensuel"].ToString()), a["Nom"].ToString(), Int32.Parse(a["Prix"].ToString()), Int32.Parse(a["Taille"].ToString()), Int32.Parse(a["Niveau"].ToString())); t.Rotation = new Vector3(float.Parse(a["Rotation"]["x"].ToString()), float.Parse(a["Rotation"]["y"].ToString()), float.Parse(a["Rotation"]["z"].ToString())); t.PosX = Int32.Parse(a["PosX"].ToString()); t.PosY = Int32.Parse(a["PosY"].ToString()); newAmenagements.Add(t); } if (type == "CompagnieTransport") { CompagnieTransport t = new CompagnieTransport(Int32.Parse(a["CoutMensuel"].ToString()), a["Nom"].ToString(), Int32.Parse(a["Prix"].ToString()), Int32.Parse(a["Taille"].ToString()), Int32.Parse(a["Niveau"].ToString())); t.Rotation = new Vector3(float.Parse(a["Rotation"]["x"].ToString()), float.Parse(a["Rotation"]["y"].ToString()), float.Parse(a["Rotation"]["z"].ToString())); t.PosX = Int32.Parse(a["PosX"].ToString()); t.PosY = Int32.Parse(a["PosY"].ToString()); newAmenagements.Add(t); } if (type == "Culture") { Culture t = new Culture(Int32.Parse(a["NiveauCulture"].ToString()), Int32.Parse(a["CoutMensuel"].ToString()), a["Nom"].ToString(), Int32.Parse(a["Prix"].ToString()), Int32.Parse(a["Taille"].ToString()), Int32.Parse(a["Niveau"].ToString())); t.Rotation = new Vector3(float.Parse(a["Rotation"]["x"].ToString()), float.Parse(a["Rotation"]["y"].ToString()), float.Parse(a["Rotation"]["z"].ToString())); t.PosX = Int32.Parse(a["PosX"].ToString()); t.PosY = Int32.Parse(a["PosY"].ToString()); newAmenagements.Add(t); } /*if (type == "Entreprise") * { * Entreprise t = new Entreprise(Int32.Parse(a["NiveauCulture"].ToString()), Int32.Parse(a["CoutMensuel"].ToString()), a["Nom"].ToString(), Int32.Parse(a["Prix"].ToString()), Int32.Parse(a["Taille"].ToString()), Int32.Parse(a["Niveau"].ToString())); * t.Rotation = new Vector3(float.Parse(a["Rotation"]["x"].ToString()), float.Parse(a["Rotation"]["y"].ToString()), float.Parse(a["Rotation"]["z"].ToString())); * t.PosX = Int32.Parse(a["PosX"].ToString()); * t.PosY = Int32.Parse(a["PosY"].ToString()); * newAmenagements.Add(t); * }*/ if (type == "Logement") { Logement t = new Logement(Int32.Parse(a["CapaciteMax"].ToString()), (ClasseSocial)Enum.Parse(typeof(ClasseSocial), a["Classe"].ToString()), float.Parse(a["NivBonheur"].ToString()), Int32.Parse(a["CoutMensuel"].ToString()), a["Nom"].ToString(), Int32.Parse(a["Prix"].ToString()), Int32.Parse(a["Taille"].ToString()), Int32.Parse(a["Niveau"].ToString())); t.Rotation = new Vector3(float.Parse(a["Rotation"]["x"].ToString()), float.Parse(a["Rotation"]["y"].ToString()), float.Parse(a["Rotation"]["z"].ToString())); t.PosX = Int32.Parse(a["PosX"].ToString()); t.PosY = Int32.Parse(a["PosY"].ToString()); newAmenagements.Add(t); } if (type == "Tourisme") { Tourisme t = new Tourisme(Int32.Parse(a["ImpactTourisme"].ToString()), Int32.Parse(a["CoutMensuel"].ToString()), a["Nom"].ToString(), Int32.Parse(a["Prix"].ToString()), Int32.Parse(a["Taille"].ToString()), Int32.Parse(a["Niveau"].ToString())); t.Rotation = new Vector3(float.Parse(a["Rotation"]["x"].ToString()), float.Parse(a["Rotation"]["y"].ToString()), float.Parse(a["Rotation"]["z"].ToString())); t.PosX = Int32.Parse(a["PosX"].ToString()); t.PosY = Int32.Parse(a["PosY"].ToString()); newAmenagements.Add(t); } if (type == "Usine") { Usine t = new Usine(Int32.Parse(a["NbrEmployeMaxAise"].ToString()), Int32.Parse(a["NbrEmployeMaxMoyenne"].ToString()), Int32.Parse(a["NbrEmployeMaxOuvriere"].ToString()), Int32.Parse(a["CoutMensuel"].ToString()), a["Nom"].ToString(), Int32.Parse(a["Prix"].ToString()), Int32.Parse(a["Taille"].ToString()), Int32.Parse(a["Niveau"].ToString())); t.Rotation = new Vector3(float.Parse(a["Rotation"]["x"].ToString()), float.Parse(a["Rotation"]["y"].ToString()), float.Parse(a["Rotation"]["z"].ToString())); t.PosX = Int32.Parse(a["PosX"].ToString()); t.PosY = Int32.Parse(a["PosY"].ToString()); newAmenagements.Add(t); } } v.Amenagements = newAmenagements; PopulateMap(v); UnityEngine.Object.FindObjectOfType <Manager>().StartGame(); UnityEngine.Object.FindObjectOfType <GameManager>().LoadGame(v); }