Exemplo n.º 1
0
        private ArtPiece AssignValues(string languageCode, TextAsset nameAsset, TextAsset descriptionAsset,
                                      TextAsset additionalInfoAsset, Technique technique, ArtPieceCreationViewModel viewModel, ArtPiece artPiece)
        {
            switch (languageCode)
            {
            case "pl":
                nameAsset.Value_pl           = viewModel.Name;
                descriptionAsset.Value_pl    = viewModel.Description;
                additionalInfoAsset.Value_pl = viewModel.AdditionalInfo;
                technique = _techniqueRepo.Techniques.Where(t => t.Name.Value_pl == viewModel.Technique).FirstOrDefault();
                break;

            case "en":
                nameAsset.Value_en           = viewModel.Name;
                descriptionAsset.Value_en    = viewModel.Description;
                additionalInfoAsset.Value_en = viewModel.AdditionalInfo;
                technique = _techniqueRepo.Techniques.Where(t => t.Name.Value_en == viewModel.Technique).FirstOrDefault();
                break;
            }

            _textRepo.SaveAsset(nameAsset);
            _textRepo.SaveAsset(descriptionAsset);
            _textRepo.SaveAsset(additionalInfoAsset);

            artPiece.AdditionalInfo = additionalInfoAsset;
            artPiece.CreationDate   = viewModel.CreationDate;
            artPiece.Description    = descriptionAsset;
            artPiece.Dimensions     = viewModel.Dimensions;
            artPiece.Technique      = technique;
            artPiece.ImageUri       = viewModel.ImageUri;
            artPiece.ForSale        = viewModel.ForSale;
            artPiece.Name           = nameAsset;

            return(artPiece);
        }
Exemplo n.º 2
0
 public bool Update(Technique technique)
 {
     try
     {
         _context.Techniques.Update(technique);
         _context.SaveChanges();
         return(true);
     }
     catch (Exception ex)
     {
         if (ex is DbUpdateException || ex is DbUpdateConcurrencyException)
         {
             return(false);
         }
         throw;
     }
 }
Exemplo n.º 3
0
        public ArtPiece CreateArtPiece(ArtPieceCreationViewModel viewModel)
        {
            var artPiece  = new ArtPiece();
            var technique = new Technique();

            var nameAsset = new TextAsset()
            {
                Key = "art_piece_name"
            };
            var descriptionAsset = new TextAsset()
            {
                Key = "art_piece_description"
            };
            var additionalInfoAsset = new TextAsset()
            {
                Key = "art_piece_additional_info"
            };

            return(AssignValues(viewModel.Language, nameAsset, descriptionAsset, additionalInfoAsset, technique, viewModel, artPiece));
        }