public async Task <IActionResult> Edit(EditModInputModel model) { if (!this.ModelState.IsValid) { return(this.View()); } this.modService.Edit(model.Id, model.Name, model.Version, model.Description); if (model.MainImage != null) { var imageUrl = await this.pictureService.UploadImage(model.MainImage, GlobalConstants.MOD_PATH_TEMPLATE, model.Name, model.Id); this.modService.AddImageUrl(model.Id, imageUrl); } if (model.MainFile != null) { var fileUrl = await this.pictureService.UploadFile(model.MainFile, GlobalConstants.File_PATH_TEMPLATE, model.Name, model.Id); this.modService.AddFileUrl(model.Id, fileUrl, model.FileName, model.FileDescription, model.MainFile.Length); } if (model.Gallery != null) { this.modService.DeleteImages(model.Id); var fileUrls = await this.pictureService.UploadImages(model.Gallery.ToList(), GlobalConstants.MOD_G_PATH_TEMPLATE, model.Name, model.Id); this.modService.AddGalleryUrls(model.Id, fileUrls.ToList()); } return(this.RedirectToAction("Details", new { Id = model.Id })); }
public IActionResult Delete(EditModInputModel model) { var userName = this.User.Identity.Name; this.modService.DeleteImages(model.Id); this.modService.DeleteFiles(model.Id); this.modService.Delete(model.Id); return(this.RedirectToAction("UserMods", "User", new { Id = userName })); }
public IActionResult Edit(string id) { var mod = this.modService.GetById(id); var model = new EditModInputModel { Id = mod.Id, Name = mod.Name, Version = mod.Version, Description = mod.Description, }; model.GalleryUrls = this.modService.GetGalleryUrlsById(id); return(this.View(model)); }