public ActionResult Edit(GameCourseInputModel model) { if (model != null && ModelState.IsValid) { var currentUserId = this.UserProfile.Id; var updatedArticle = this.Mapper.Map <GameCourse>(model); var imageUploader = new ImageUplouder(); var images = new HashSet <Image>(); string folderPath = this.Server.MapPath(WebConstants.ImagesMainPathMap + currentUserId); if (model.Files != null && model.Files.Count() > 0) { foreach (var file in model.Files) { if (file != null && (file.ContentType == WebConstants.ContentTypeJpg || file.ContentType == WebConstants.ContentTypePng) && file.ContentLength < WebConstants.MaxImageFileSize) { images.Add(imageUploader.UploadImage(file, folderPath, currentUserId)); } } } images.ForEach(x => updatedArticle.Images.Add(x)); this.courses.Update(model.Id, updatedArticle); return(this.RedirectToAction("Course", "Academy", new { area = "", id = model.Id })); } return(this.View(model)); }
public ActionResult Create(GameCourseInputModel model) { if (model != null && this.ModelState.IsValid) { var currentUserId = this.UserProfile.Id; var newArticle = this.Mapper.Map <GameCourse>(model); var imageUploader = new ImageUplouder(); var images = new HashSet <Image>(); string folderPath = this.Server.MapPath(WebConstants.ImagesMainPathMap + currentUserId); if (model.Files != null && model.Files.Count() > 0) { foreach (var file in model.Files) { if (file != null && (file.ContentType == WebConstants.ContentTypeJpg || file.ContentType == WebConstants.ContentTypePng) && file.ContentLength < WebConstants.MaxImageFileSize) { images.Add(imageUploader.UploadImage(file, folderPath, currentUserId)); } } } var trainer = this.users.UserById(currentUserId).FirstOrDefault(); newArticle.Coaches.Add(trainer); var result = this.courses.Create(newArticle); return(this.RedirectToAction("Course", "Academy", new { area = "", id = result })); } return(this.View(model)); }
public ActionResult Edit(GameCourseInputModel model) { if (model != null && this.ModelState.IsValid) { var currentUserId = this.UserProfile.Id; var updatedCourse = this.Mapper.Map <CoursePlan>(model); this.objectives.Update(model.Id, updatedCourse); return(this.RedirectToAction("CourseObjective", "Academy", new { area = string.Empty, id = model.Id })); } return(this.View(model)); }
public ActionResult Create(GameCourseInputModel model) { if (model != null && this.ModelState.IsValid) { var currentUserId = this.UserProfile.Id; var newCourse = this.Mapper.Map <CoursePlan>(model); newCourse.CreatorId = currentUserId; var result = this.objectives.Create(newCourse); return(this.RedirectToAction("CourseObjective", "Academy", new { area = string.Empty, id = result })); } return(this.View(model)); }