public ActionResult CreateAntrenori() { Antrenori antrenor = new Antrenori(); antrenor.Clnt = new List <Client>(); return(View()); }
public ActionResult DeleteAntrenori(int id) { Antrenori antre = db.Antrenori.Find(id); if (antre != null) { db.Antrenori.Remove(antre); db.SaveChanges(); return(RedirectToAction("Index")); } return(HttpNotFound(" " + id.ToString())); }
public ActionResult Details(int?id) { if (id.HasValue) { Antrenori antre = db.Antrenori.Find(id); if (antre != null) { return(View(antre)); } return(HttpNotFound("Nu s-a putut gasi antrenorul cu id-ul: " + id.ToString())); } return(HttpNotFound("Lipseste id-ul antrenorului!")); }
public ActionResult UpdateAntrenori(int?id) { if (id.HasValue) { Antrenori antre = db.Antrenori.Find(id); if (antre == null) { return(HttpNotFound("Nu s-a putut gasi antrenorul cu id-ul:" + id.ToString())); } return(View(antre)); } return(HttpNotFound("Nu exista antrenorul cu paramtreul specificat")); }
public ActionResult CreateAntrenori(Antrenori antrenoriRequest) { try { if (ModelState.IsValid) { //vom sterge ulterior // antrenoriRequest.Clnt = (ICollection<Client>)db.Clienti.FirstOrDefault( // p => p.IdClient.Equals(1)); db.Antrenori.Add(antrenoriRequest); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(antrenoriRequest)); } catch (Exception e) { return(View(antrenoriRequest)); } }
public ActionResult UpdateAntrenori(int id, Antrenori antreRequest) { Antrenori antre = db.Antrenori.SingleOrDefault(b => b.IdAntrenori.Equals(id)); try { if (ModelState.IsValid) { if (TryUpdateModel(antre)) { antre.Nume = antreRequest.Nume; db.SaveChanges(); } RedirectToAction("Index"); } return(View(antreRequest)); } catch (Exception e) { return(View(antreRequest)); } }