public ActionResult Edit([Bind(Include = "Id,Name,Surname,About,Image")] Fermer fermer, HttpPostedFileBase file) { if (ModelState.IsValid) { fermer.Image = Comman.WorkWithFile.Upload("~/Uploads/", file); db.Entry(fermer).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(fermer)); }
public ActionResult DeleteConfirmed(int id) { Fermer fermer = db.Fermers.Find(id); if (System.IO.File.Exists("~/Uploads/" + fermer.Image)) { System.IO.File.Delete("~/Uploads/" + fermer.Image); } db.Fermers.Remove(fermer); db.SaveChanges(); return(RedirectToAction("Index")); }
// GET: Admin/Fermers/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Fermer fermer = db.Fermers.Find(id); if (fermer == null) { return(HttpNotFound()); } return(View(fermer)); }
public void StartGame(Button startButton) { if(GameStarted) { RestartGame(); return; } GameStarted = true; _timeFromstart = 0; Time.timeScale = 1; // unpause game if(startButton != null) { startButton.GetComponentInChildren<Text>().text = "Restart"; } _lowerLeft = Camera.main.ScreenToWorldPoint(new Vector3(0, 0, 0)); _upperRight = Camera.main.ScreenToWorldPoint(new Vector3(Screen.width, Screen.height, 0)); _upperRight.y -= 1f; // for top buttons Backplate.size = _upperRight - _lowerLeft; Grass.localScale = _upperRight - _lowerLeft; var dogs = new Dog[DogCount]; for(int i = 0; i < DogCount; i++) { dogs[i] = Instantiate(PrefabDog.gameObject).GetComponent<Dog>(); dogs[i].Speed = DogsSpeed; dogs[i].transform.position = new Vector2(Random.Range(_lowerLeft.x + Bound, _upperRight.x - Bound), Random.Range(_lowerLeft.y + Bound, _upperRight.y - Bound)); } var ponies = new Pony[PonyCount]; for(int i = 0; i < PonyCount; i++) { ponies[i] = Instantiate(PrefabPony.gameObject).GetComponent<Pony>(); ponies[i].Speed = PoniesSpeed; ponies[i].transform.position = new Vector2(Random.Range(_lowerLeft.x + Bound, _upperRight.x - Bound), Random.Range(_lowerLeft.y + Bound, _upperRight.y - Bound)); } var iDogs = new List<ICreature>(dogs); var iPonies = new List<ICreature>(ponies); Fermer = new Fermer(iDogs, iPonies); }