public ActionResult DeleteConfirmed(int id) { //TODO: This action need to be deeply reviewed drill drill = db.drills.Find(id); db.drills.Remove(drill); db.SaveChanges(); return(RedirectToAction("Index")); }
// GET: club/Delete/5 public ActionResult Delete(int?id) { //TODO: This action need to be deeply reviewed if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } drill drill = db.drills.Find(id); if (drill == null) { return(HttpNotFound()); } return(View(drill)); }
public ActionResult Edit([Bind(Include = "ID,drill_target,drill_title,goals,execution," + "variations,progression,coachingtips,organization,competition,drill_emphasisid,agelevel_id,level_play," + "drill_structure,drill_typeid,playernumbers,participating_positionsid,drill_locationid," + "drill_duration,fieldsize")] drill drill) { //TODO: This action need to be deeply reviewed if (ModelState.IsValid) { //TODO: Update material lists //TODO: Update skills list db.Entry(drill).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(drill)); }
/// <summary> /// Add new drill to database. /// </summary> /// <param name="drill">new drill instance.</param> public void AddNewDrill(drill drill) { this.drillRepo.Addnew(drill); }
public void SetUp() { this.testDrills = new List <drill>() { new drill() { drill_id = 1, drill_fuel = 3, drill_score = 11, drill_speed = 20, drill_storage = 10, drill_x = 3, drill_y = 3 }, new drill() { drill_id = 2, drill_fuel = 4, drill_score = 12, drill_speed = 21, drill_storage = 11, drill_x = 4, drill_y = 5 }, new drill() { drill_id = 3, drill_fuel = 5, drill_score = 13, drill_speed = 22, drill_storage = 12, drill_x = 6, drill_y = 6 }, new drill() { drill_id = 4, drill_fuel = 6, drill_score = 14, drill_speed = 23, drill_storage = 13, drill_x = 14, drill_y = 13 }, new drill() { drill_id = 5, drill_fuel = 7, drill_score = 15, drill_speed = 25, drill_storage = 17, drill_x = 15, drill_y = 12 }, }; this.testBricks = new List <brick>() { new brick() { brick_id = 1, brick_type = "gold", brick_x = 10, brick_y = 10 }, new brick() { brick_id = 2, brick_type = "silver", brick_x = 15, brick_y = 22 }, new brick() { brick_id = 3, brick_type = "bronze", brick_x = 24, brick_y = 11 }, new brick() { brick_id = 4, brick_type = "gold", brick_x = 16, brick_y = 24 }, new brick() { brick_id = 5, brick_type = "silver", brick_x = 11, brick_y = 34 }, }; this.testConnections = new List <conn>() { new conn() { conn_id = 1, conn_drill_id = 1, conn_brick_id = 1 }, new conn() { conn_id = 2, conn_drill_id = 2, conn_brick_id = 2 }, new conn() { conn_id = 3, conn_drill_id = 3, conn_brick_id = 3 }, new conn() { conn_id = 4, conn_drill_id = 4, conn_brick_id = 4 }, new conn() { conn_id = 5, conn_drill_id = 5, conn_brick_id = 5 }, }; this.testDrill = new drill() { drill_id = 2, drill_fuel = 3, drill_score = 10, drill_speed = 20, drill_storage = 10, drill_x = 3, drill_y = 3 }; this.testBrick = new brick() { brick_id = 2, brick_type = "gold", brick_x = 5, brick_y = 6 }; this.testConn = new conn() { conn_id = 1, conn_brick_id = 2, conn_drill_id = 2 }; this.drillRepo = new Mock <IDrillRepository>(MockBehavior.Loose); this.drillRepo.Setup(c => c.GetAll()).Returns(this.testDrills.AsQueryable()); this.brickRepo = new Mock <IBrickRepository>(MockBehavior.Loose); this.brickRepo.Setup(c => c.GetAll()).Returns(this.testBricks.AsQueryable()); this.connRepo = new Mock <IConnRepository>(MockBehavior.Loose); this.connRepo.Setup(c => c.GetAll()).Returns(this.testConnections.AsQueryable()); this.gameModel = new GameModel(500, 500); this.dbLogic = new DbLogic(this.gameModel, this.drillRepo.Object, this.brickRepo.Object, this.connRepo.Object); }
public ActionResult Create([Bind(Include = "ID,drill_target,drill_title,drill_goals,drill_execution," + "drill_variations,drill_progression,drill_coachingtips,drill_organization,drill_competition,drill_emphasisid,agelevel_id,drill_levelplay," + "drill_structure,drill_typeid,drill_playernumbers,participating_positionsid,drill_locationid," + "drill_duration,drill_fieldsize")] drillinputmodel drillentry) { string[] skillids = this.Request["drillskillsid"].Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries) .Where(a => a != "false").ToArray(); string[] materialids = this.Request["drillmaterialsid"].Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries) .Where(a => a != "false").ToArray(); string[] materialnum = this.Request["drillmaterialsnum"].Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries) .Where(a => a != "false").ToArray(); //1. Convert the entry to Db Model if (ModelState.IsValid == false) { drill dbdrill = new drill { drill_competition = drillentry.drill_competition, agelevel_id = drillentry.agelevel_id, drill_coachingtips = drillentry.drill_coachingtips, drill_duration = drillentry.drill_duration, drill_emphasisid = drillentry.drill_emphasisid, drill_execution = drillentry.drill_execution, drill_fieldsize = drillentry.drill_fieldsize, drill_goals = drillentry.drill_goals, drill_levelplay = drillentry.drill_levelplay, drill_locationid = drillentry.drill_locationid, drill_organization = drillentry.drill_organization, drill_playernumbers = drillentry.drill_playernumbers, drill_progression = drillentry.drill_progression, drill_structure = drillentry.drill_structure, drill_target = drillentry.drill_target, drill_title = drillentry.drill_title, drill_typeid = drillentry.drill_typeid, drill_variations = drillentry.drill_variations, participating_positionsid = drillentry.participating_positionsid }; //2. Check for validity of all entries //3. Save the drill //4. Save drill related objects using (TransactionScope trans = new TransactionScope()) { //TODO: This action need to be deeply reviewed db.drills.Add(dbdrill); //db.SaveChanges(); //TODO: insert materials list for (int index = 0; index < materialids.Length; index++) { drill_materials mat = new drill_materials() { drill_id = dbdrill.ID, material_id = System.Convert.ToInt32(materialids[index]), number = System.Convert.ToInt32(materialnum[index]) }; db.drill_materials.Add(mat); } //TODO: inser skills list for (int index = 0; index < skillids.Length; index++) { drill_skills skl = new drill_skills() { drill_id = dbdrill.ID, skill_id = System.Convert.ToInt32(skillids[index]) }; db.drillskills.Add(skl); } db.SaveChanges(); trans.Complete(); } return(RedirectToAction("Index")); } return(View(drillentry)); }
void Start() { drill = GetComponentInParent <drill>(); }