/// <summary> /// GET: Artist/Delete/5 /// </summary> /// <param name="id"></param> /// <param name="concurrencyError"></param> /// <returns></returns> public async Task <ActionResult> Delete(long?id, bool?concurrencyError) { if (id == null) { return(NotFound()); } ArtworkModel artwork = await _context.Artworks.FindAsync(id); if (artwork == null) { if (concurrencyError.GetValueOrDefault()) { return(RedirectToAction("Index")); } } if (concurrencyError.GetValueOrDefault()) { ViewBag.ConcurrencyErrorMessage = "The record you attempted to delete " + "was modified by another user after you got the original values. " + "The delete operation was canceled and the current values in the " + "database have been displayed. If you still want to delete this " + "record, click the Delete button again. Otherwise " + "click the Back to List hyperlink."; } return(View(artwork)); }
private ArtworkEditModel GetArtworkEditModel(ArtworkModel artworkModel) { var model = new ArtworkEditModel(); model.Artwork = artworkModel; var artists = ArtistBussinessLogic.Instance.GetArtists(); model.SourceArtists = IdNameModelTranslator <Artist> .Instance.Translate(artists); var artworkTypes = ArtworkBussinessLogic.Instance.GetArtworkTypes(); model.SourceArtworkTypes = ArtworkTypeModelTranslator.Instance.Translate(artworkTypes); var genres = ArtistBussinessLogic.Instance.GetGenres(); model.SourceGenres = IdNameModelTranslator <Genre> .Instance.Translate(genres); var periods = ArtworkBussinessLogic.Instance.GetPeriods(); model.SourceArtPeriods = IdNameModelTranslator <ArtPeriod> .Instance.Translate(periods); var places = ArtworkBussinessLogic.Instance.GetPlaces(); model.SourceArtPlaces = IdNameModelTranslator <ArtPlace> .Instance.Translate(places); var auctionTypes = ArtworkBussinessLogic.Instance.GetAuctionTypes(); model.SourceAuctionTypes = IdNameModelTranslator <AuctionType> .Instance.Translate(auctionTypes); return(model); }
public ArtworksRenderer(ArtworkModel model) { _panelActive = model.Active; _artworks = model.UserArtworks; _currentUser = model.CurrentUser; _next = model.Next.next; }
public IActionResult Edit(Guid ArtworkId) { // get artwork from database (ArtworkModel) ArtworkModel model = _artworkDataManager.GetOneArtwork(ArtworkId); ArtworkViewModel viewModel = new ArtworkViewModel(); viewModel.Id = model.Id; viewModel.Title = model.Title; ArtistModel[] artists = _artistDataManager.GetArtists(); var artistList = artists.Select(x => new { x.Id, x.FullName }).ToList(); viewModel.ArtistDropdown = new SelectList(artistList, "Id", "FullName", model.Artist.FullName); StyleModel[] styles = _artworkDataManager.GetStyles(); var styleList = styles.Select(x => new { x.Id, x.Style }).ToList(); viewModel.StyleDropdown = new SelectList(styleList, "Id", "Style", model.Style.Style); viewModel.Year = model.Year; viewModel.Description = model.Description; viewModel.Type = model.Type; viewModel.Price = model.Price; viewModel.Availability = model.Availability; // return view return(View(viewModel)); }
public IActionResult BuyArtwork(Guid ArtworkId) { // get artwork from database (ArtworkModel) ArtworkModel model = _artworkDataManager.GetOneArtwork(ArtworkId); return(View("OrderArtwork", model)); }
public JsonResult Update(ArtworkModel model) { var artwork = ArtworkModelTranslator.Instance.Translate(model); ArtworkBussinessLogic.Instance.Update(artwork); var result = new ResultModel(true, "update successfully!"); return(Json(result)); }
public async Task <IActionResult> DeleteConfirmed(long id) { ArtworkModel artwork = await _context.Artworks .SingleAsync(i => i.ArtistId == id); _context.Artworks.Remove(artwork); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); }
public ActionResult Add() { var artwork = new ArtworkModel(); var model = GetArtworkEditModel(artwork); var artistIdStr = Request.QueryString["artistId"]; int artistId; if (int.TryParse(artistIdStr, out artistId)) { model.Artwork.ArtistId = artistId; } return(View("Edit", model)); }
internal void AddOrder(string address, ArtworkModel artwork, UserModel user) { var item = new OrderModel() { Address = address, Date = DateTime.Now, Artwork = artwork, User = user }; _dbContext.Orders.Add(item); _dbContext.SaveChanges(); }
public IActionResult AddOrder(string address, Guid ArtworkId) { ArtworkModel artworkmodel = _artworkDataManager.GetOneArtwork(ArtworkId); var userId = _userManager.GetUserId(User); UserModel usermodel = _artworkDataManager.GetOneUser(userId); _artworkDataManager.AddOrder(address, artworkmodel, usermodel); _artworkDataManager.EditAvailabilityAfterBuying(ArtworkId); HomeModel homemodel = new HomeModel(); homemodel.Message = "Your Order has been accepted!"; return(RedirectToAction("Index", "Home", homemodel)); }
internal void AddArtwork(string title, ArtistModel artist, StyleModel style, int year, string description, string type, float price, bool availability) { var item = new ArtworkModel() { Title = title, Artist = artist, Style = style, Year = year, Description = description, Type = type, Price = price, Availability = availability }; _dbContext.Artworks.Add(item); _dbContext.SaveChanges(); }
/// <summary> /// GET: Artwork/Details/5 /// returns the details of the selected artwork /// </summary> /// <param name="id"></param> /// <returns></returns> public async Task <ActionResult> Details(long?id) { if (id == null) { return(NotFound()); } ArtworkModel artwork = await _context.Artworks.FindAsync(id); if (artwork == null) { return(NotFound()); } artwork.Artist = _context.Artists.FirstOrDefault(user => user.ArtistId == artwork.ArtistId); return(View(artwork)); }
public async Task <ActionResult> Delete(ArtworkModel artwork) { try { _context.Entry(artwork).State = EntityState.Deleted; await _context.SaveChangesAsync(); return(RedirectToAction("Index")); } catch (DbUpdateConcurrencyException) { return(RedirectToAction("Delete", new { concurrencyError = true, id = artwork.ArtworkId })); } catch (DataException /* dex */) { //Log the error (uncomment dex variable name after DataException and add a line here to write a log. ModelState.AddModelError(string.Empty, "Unable to delete. Try again, and if the problem persists contact your system administrator."); return(View(artwork)); } }
public async Task <ActionResult> Edit(long?id, [Bind("ArtworkId,Name,Description,Creation,ArtistId,Type,SourceMeta,Guid,ObjectUrl,ImageUrl,IconUrl,ThumbUrl,SignUrl,TradeUrl,WpId,PrefabName,MarshalCode,SizeDescription,Year,EditionSize,Color,Size,ApSize,Preload,Active,IosFile,AndroidFile,ImageUrlFile,IconUrlFile,ThumbUrlFile,SignUrlFile,TradeUrlFile")] ArtworkModel artworkModel) { if (id == null) { return(NotFound()); } if (ModelState.IsValid) { var artworkToUpdate = await _context.Artworks.Include(x => x.Artist).FirstOrDefaultAsync(m => m.ArtworkId == id); List <IFormFile> allFiles = new List <IFormFile> { artworkModel.IconUrlFile, artworkModel.ImageUrlFile, artworkModel.ThumbUrlFile, artworkModel.TradeUrlFile, artworkModel.SignUrlFile, artworkModel.IosFile, artworkModel.AndroidFile }; if (await TryUpdateModelAsync <ArtworkModel>( artworkToUpdate, "", i => i.Name, i => i.Description, i => i.ArtistId, i => i.Type, i => i.SourceMeta, i => i.ObjectUrl, i => i.PrefabName, i => i.MarshalCode, i => i.SizeDescription, i => i.Size, i => i.Active, i => i.Year, i => i.EditionSize, i => i.Color, i => i.ImageUrl, i => i.ThumbUrl, i => i.IconUrl, i => i.TradeUrl, i => i.SignUrl)) { try { #region Upload File to azure storage foreach (IFormFile file in allFiles) { if (file == null) { continue; } //create file class to use uploading files AzureBlobFile azureBlobFile = new AzureBlobFile(InterfaceFileTypes.Artwork, file, await file.GetBytes(), artworkToUpdate.Artist.Name, artworkToUpdate.Name, Configuration.GetConnectionString("AccessKey"), Configuration.GetConnectionString("ContainerName")); //create azure storace service BlobStorageService objBlobService = new BlobStorageService(azureBlobFile.AccessKey, azureBlobFile.ContainerName); //upload file to azure storage string uploadedFileName = objBlobService.UploadFileToBlob(azureBlobFile); //if the previous file exists delete //string previousPropertyBlobUrlToUpdate = Helper.Helper.GetPropertyValue(artworkToUpdate, azureBlobFile.PropertyName); //If necessary, open the remove option //if (!string.IsNullOrEmpty(previousPropertyBlobUrlToUpdate)) //{ // objBlobService.DeleteBlobData(previousPropertyBlobUrlToUpdate, azureBlobFile.FilePath); //} //Set azure storage file nime into the model property Helper.Helper.UpdateProperty(artworkToUpdate, azureBlobFile.PropertyName, uploadedFileName); } #endregion await _context.SaveChangesAsync(); } catch (DbUpdateException ex) { _logger.LogError($"Artwork -> Edit -> exception: {ex.ToString()}"); //Log the error (uncomment ex variable name and write a log.) ModelState.AddModelError("", "Unable to save changes. " + "Try again, and if the problem persists, " + "see your system administrator."); } return(RedirectToAction(nameof(Index))); } } PopulateTypesDropDownList(artworkModel.Type); PopulateArtistsDropDownList(artworkModel.ArtistId); return(View(artworkModel)); }
public async Task <IActionResult> Create([Bind("Name,Description,ArtistId,Type,SourceMeta,WpId,PrefabName,MarshalCode,SizeDescription,Year,EditionSize,Color,Size,Active,IosFile,AndroidFile,ImageUrlFile,IconUrlFile,ThumbUrlFile,SignUrlFile,TradeUrlFile")] ArtworkModel artworkModel) { if (ModelState.IsValid) { artworkModel.Active = true; artworkModel.Guid = Guid.NewGuid().ToString(); artworkModel.Creation = DateTime.UtcNow; artworkModel.WpId = Guid.NewGuid().ToString(); artworkModel.ApSize = 1; artworkModel.Preload = false; artworkModel.Artist = await _context.Artists.FirstOrDefaultAsync(artist => artist.ArtistId == artworkModel.ArtistId); #region Upload File to azure storage List <IFormFile> allFiles = new List <IFormFile> { artworkModel.IconUrlFile, artworkModel.ImageUrlFile, artworkModel.ThumbUrlFile, artworkModel.TradeUrlFile, artworkModel.SignUrlFile, artworkModel.IosFile, artworkModel.AndroidFile }; foreach (IFormFile file in allFiles) { if (file == null) { continue; } //create file class to use uploading files AzureBlobFile azureBlobFile = new AzureBlobFile(InterfaceFileTypes.Artwork, file, await file.GetBytes(), artworkModel.Artist.Name, artworkModel.Name, Configuration.GetConnectionString("AccessKey"), Configuration.GetConnectionString("ContainerName")); //create azure storace service BlobStorageService objBlobService = new BlobStorageService(azureBlobFile.AccessKey, azureBlobFile.ContainerName); //upload file to azure storage string uploadedFileName = objBlobService.UploadFileToBlob(azureBlobFile); //Set azure storage file nime into the model property Helper.Helper.UpdateProperty(artworkModel, azureBlobFile.PropertyName, uploadedFileName); } #endregion _context.Add(artworkModel); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } PopulateTypesDropDownList(0); PopulateArtistsDropDownList(0); return(View(artworkModel)); }
public ArtworksController(LoginController login) { _login = login; _model = new ArtworkModel(); }