public virtual bool UpdateBoxer(Record NewRecord) { try { Won = NewRecord.Won; Lost = NewRecord.Lost; Drawn = NewRecord.Drawn; KO = NewRecord.KO; return true; } catch { return false; } }
public virtual bool UpdateBoxer(Boxer NewBoxer, Record NewRecord) { try { FirstName = NewBoxer.FirstName; LastName = NewBoxer.LastName; DateOfBirth = NewBoxer.DateOfBirth; Weight = NewBoxer.Weight; Boxrec = NewBoxer.Boxrec; Credentials = NewBoxer.Credentials; Nationality = NewBoxer.Nationality; RankingPts = NewBoxer.RankingPts; if (Record == null) { Record = new Record(); Record.Boxer = this; } Record.UpdateBoxer(NewRecord); return true; } catch { return false; } }
public ActionResult EditBoxer(Boxer boxer, Record record, int Id, int Nationality, int Weight, bool Prospect) { var Boxerreppository = GetRepository<Boxer>(); var Nationalityrep = GetRepository<Nationality>(); var Weightrep = GetRepository<Weight>(); var repRecord = GetRepository<Record>(); Boxer dbBoxer = Boxerreppository.Get(Id); boxer.Nationality = Nationalityrep.Get(Nationality); boxer.Weight = Weightrep.Get(Weight); //Add or remove the boxer depending on checkbox! if (Prospect & !dbBoxer.IsProspect) { var ProspectRep = GetRepository<Prospect>(); var prospect = new Prospect { Boxer = dbBoxer }; ProspectRep.Add(prospect); } else if (dbBoxer.IsProspect & !Prospect) { var ProspectRep = GetRepository<Prospect>(); ProspectRep.Delete(ProspectRep.Get(dbBoxer.Id)); } if (dbBoxer.UpdateBoxer(boxer, record) == true) { repRecord.Add(dbBoxer.Record); DataSession.Save(dbBoxer); } return Redirect("/ben"); }
public ActionResult CreateBoxer(string FirstName, string LastName, string DateOfBirth, string Weight, string BoxRec, string Credentials, string Nationality, string RankingPts, string Won, string KO, string Lost, string Drawn, bool Prospect) { var repNationality = GetRepository<Nationality>(); var repWeight = GetRepository<Weight>(); var repBoxer = GetRepository<Boxer>(); var repRecord = GetRepository<Record>(); var repProspect = GetRepository<Prospect>(); var boxer = new Boxer { FirstName = FirstName, LastName = LastName, Boxrec = BoxRec, Credentials = Credentials != string.Empty ? Credentials : null, Weight = repWeight.Get(int.Parse(Weight)), Nationality = repNationality.Get(int.Parse(Nationality)), RankingPts = decimal.Parse(RankingPts) }; if (!string.IsNullOrEmpty(DateOfBirth)) boxer.DateOfBirth = DateTime.Parse(DateOfBirth); DataSession.Save(boxer); //Create boxers Record var record = new Record { Boxer = boxer, Won = int.Parse(Won), KO = int.Parse(KO), Lost = int.Parse(Lost), Drawn = int.Parse(Drawn) }; repRecord.Add(record); //Match Boxer a prospect if (Prospect) { var prospect = new Prospect { Boxer = boxer }; repProspect.Add(prospect); } return Redirect("/ben"); }