コード例 #1
0
 public async Task<string> Edit(EditPictureModel editPictureModel)
 {
     try
     {
         var savePictureDto = new SavePictureDto
         {
             Id = editPictureModel.Picture.Id,
             Name = editPictureModel.Picture.Name,
             StyleId = _stylesRepository.GetIdByName(editPictureModel.Picture.Style),
             Year = editPictureModel.Picture.Year,
             PainterId = editPictureModel.Picture.PainterId,
             ImageUrl = editPictureModel.Picture.ImageUrl
         };
         await _picturesRepository.SavePicture(savePictureDto);
         return "saved";
     }
     catch (Exception e)
     {
         _logger.Error(e, "Редактирование картины");
         return "Save error";
     }
 }
コード例 #2
0
        public async Task<ActionResult> Edit(long id)
        {
            var picture = await _picturesRepository.GetPicture(id);

            IEnumerable<PainterDto> painters = await _paintersRepository.GetPainters();

            var editPicture = new EditPictureModel
            {
                Picture = new Picture
                {
                    Id = picture.Id,
                    Name = picture.Name,
                    Style = picture.Style,
                    Year = picture.Year,
                    PainterId = picture.PainterId,
                    ImageUrl = picture.ImageUrl,
                    Guid = picture.Guid
                },
                Painters = painters
            };

            return View("Edit", editPicture);
        }