public ActionResult Index() { var exercises = RavenSession.Query <Exercise>().Where(x => x.Master).Take(1024); RavenSession.Advanced.MaxNumberOfRequestsPerSession = 10000; foreach (var exer in exercises) { var newMaster = new MasterExercise(); newMaster.AccountId = 0; newMaster.Name = exer.Name; newMaster.Categories = exer.Categories; newMaster.ClinicId = 0; newMaster.Description = exer.Description; newMaster.ExerciseDetails = exer.ExerciseDetails; newMaster.MasterExerciseId = exer.Id; newMaster.Master = true; newMaster.UserId = 0; newMaster.VideoId = exer.VideoId; newMaster.CreatedOn = DateTime.Now; RavenSession.Store(newMaster); } RavenSession.SaveChanges(); return(View()); }
public ActionResult Create(ExerciseViewModel postedModel) { try { if (!ModelState.IsValid) { return(View(postedModel)); } var newExercise = new MasterExercise(); newExercise.Name = postedModel.Name.Trim(); newExercise.Description = postedModel.Description; newExercise.CreatedOn = DateTime.Now; string[] lines = postedModel.Categories.Split(new string[] { "\r\n", "\n" }, StringSplitOptions.None); newExercise.Categories = new List <string>(lines.Where(x => !string.IsNullOrWhiteSpace(x))); if (!string.IsNullOrWhiteSpace(postedModel.VideoId)) { newExercise.VideoId = postedModel.VideoId.Trim(); } RavenSession.Store(newExercise); RavenSession.SaveChanges(); if (!string.IsNullOrWhiteSpace(postedModel.VideoId)) { var success = Thumbnailer.GenerateThumbs(newExercise.Id, newExercise.VideoId); if (!success) { this.WarnUser("We couldn't generate a thumbnail image for this exercise. The video id could be wrong or Vimeo may be not be " + "responding. We'll try to generate the thumbnail again but it would be a good idea to double" + "check the video id. Sorry about that."); } } HighFive("New master exercise created ok."); return(RedirectToAction("List")); } catch { return(View(postedModel)); } }