public Contract.Training Add(Contract.Training training) { Model.Training dbTraining = AddMetaData(training); if (dbTraining.TrainingId == 0) { Console.WriteLine("fdsa"); } AddPhoto(training.Pictures, dbTraining.TrainingId); AddGpx(training.Gpx, dbTraining.TrainingId); training.ExternalIdList.ForAll(x => UpdateExternalId(dbTraining.TrainingId, x.Key, x.Value)); return(this.Mapper.Map <Contract.Training>(dbTraining)); }
private Model.Training AddMetaData(Contract.Training training) { Model.Training dbTraining = this.Mapper.Map <Model.Training>(training); var t = this.Context.Training.SingleOrDefault(x => x.Account == training.Account && x.Start == training.Start && x.End == training.End && x.Sport == training.Sport); if (t == null) { this.Context.Training.Add(dbTraining); this.Context.SaveChanges(); return(dbTraining); } else { return(t); } }
public Training Add(Contract.Training training) { var r = this.Application.Add(training); return(r); }