public ActionResult Create(SellingItemInputModel model) { if (model != null && ModelState.IsValid) { var currentUserId = this.UserProfile.Id; var newArticle = this.Mapper.Map <SellingItem>(model); var imageUploader = new ImageUplouder(); var images = new HashSet <Image>(); string folderPath = 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)); } } } newArticle.SellerId = currentUserId; newArticle.Images = images; var result = this.sellingItems.Create(newArticle); return(this.RedirectToAction("Details", "Shop", new { area = "", id = result })); } return(this.View(model)); }
public ActionResult Create(TutorialInputViewModel model) { if (model != null && this.ModelState.IsValid) { var currentUserId = this.UserProfile.Id; var newArticle = this.Mapper.Map <Tutorial>(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)); } } } newArticle.Type = TutorialType.FPS; newArticle.AuthorId = currentUserId; newArticle.Images = images; var result = this.tutorials.Create(newArticle); // TODO: Fix Redirect return(this.RedirectToAction("Details", "FPS", new { area = "", id = result })); } return(this.View(model)); }
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 Edit(TutorialInputViewModel model) { if (model != null && this.ModelState.IsValid) { var currentUserId = this.UserProfile.Id; var updatedArticle = this.Mapper.Map <Tutorial>(model); var imageUploader = new ImageUplouder(); var images = new HashSet <Image>(); string folderPath = this.Server.MapPath(WebConstants.ImagesMainPathMap + currentUserId); if (model.Files != null && model.Files.Any()) { 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.tutorials.Update(model.Id, updatedArticle); // TODO: Fix Redirect return(this.RedirectToAction("Details", "FPS", 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)); }