public void Delete(int id) { Caddy c = utOfWork.CaddyRepository.GetById(id); utOfWork.CaddyRepository.Delete(c); utOfWork.Commit(); }
public ActionResult DeleteConfirmed(int id) { Caddy caddy = db.Caddy.Find(id); db.Caddy.Remove(caddy); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "Id,xPos,yPos,zPos,State,ClientId")] Caddy caddy) { if (ModelState.IsValid) { db.Entry(caddy).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.ClientId = new SelectList(db.Client, "Id", "Name", caddy.ClientId); return(View(caddy)); }
// POST: odata/Caddies public IHttpActionResult Post(Caddy caddy) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.Caddy.Add(caddy); db.SaveChanges(); return(Created(caddy)); }
static void Main(string[] args) { Player player1 = new Player("Harvey", ClubType.GRAPHITE, BallType.MAXFLI, GloveType.CALLOWAY); Player player2 = new Player("Penick", ClubType.STEEL, BallType.SRIXON, GloveType.FOOTJOY); Caddy caddy = new Caddy("Bones", player1, player2); // Need to set the course in caddy - perhaps from args. // Need to set the scoring method in caddy = perhaps from args. Console.WriteLine(caddy.ToString()); // Simulate the game. caddy.Game(); } /* end Main */
// GET: Caddies/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Caddy caddy = db.Caddy.Find(id); if (caddy == null) { return(HttpNotFound()); } return(View(caddy)); }
// DELETE: odata/Caddies(5) public IHttpActionResult Delete([FromODataUri] int key) { Caddy caddy = db.Caddy.Find(key); if (caddy == null) { return(NotFound()); } db.Caddy.Remove(caddy); db.SaveChanges(); return(StatusCode(HttpStatusCode.NoContent)); }
// GET: Caddies/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Caddy caddy = db.Caddy.Find(id); if (caddy == null) { return(HttpNotFound()); } ViewBag.ClientId = new SelectList(db.Client, "Id", "Name", caddy.ClientId); return(View(caddy)); }
// GET: Caddies/Create public ActionResult Create() { Caddy caddy = new Caddy(); caddy.xPos = 0; caddy.yPos = 0; caddy.zPos = 0; caddy.ClientId = null; caddy.State = "Free"; Log log = new Log(); log.Trigger = "Caddy"; log.Message = "New Caddy added"; log.Time = DateTime.Now; log.Cide = "4"; db.Caddy.Add(caddy); db.Log.Add(log); db.SaveChanges(); ViewBag.ClientId = new SelectList(db.Client, "Id", "Name"); return(RedirectToAction("Index")); }
public ActionResult Create([Bind(Include = "Id,xPos,yPos,zPos,State,ClientId")] Caddy caddy) { if (ModelState.IsValid) { caddy.xPos = 0; caddy.yPos = 0; caddy.zPos = 0; caddy.ClientId = null; caddy.State = "Free"; Log log = new Log(); log.Trigger = "Caddy"; log.Message = "New Caddy added"; log.Time = DateTime.Now; log.Cide = "4"; db.Caddy.Add(caddy); db.Log.Add(log); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.ClientId = new SelectList(db.Client, "Id", "Name", caddy.ClientId); return(View(caddy)); }
// PUT: odata/Caddies(5) public IHttpActionResult Put([FromODataUri] int key, Delta <Caddy> patch) { Validate(patch.GetEntity()); if (!ModelState.IsValid) { return(BadRequest(ModelState)); } Caddy caddy = db.Caddy.Find(key); if (caddy == null) { return(NotFound()); } patch.Put(caddy); try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!CaddyExists(key)) { return(NotFound()); } else { throw; } } return(Updated(caddy)); }
public void AddNew(Caddy c) { utOfWork.CaddyRepository.Add(c); utOfWork.Commit(); }