public IActionResult Edit(Guid?id) { if (id == null) { return(NotFound().WithError(LOCALIZATION_ERROR_NOT_FOUND)); } try { ViewBag.Cities = _cityService.GetAllAsLookup(CountryId); ViewBag.Categories = _categoryService.GetAllAsLookup(CountryId); var ad = _adService.GetAdAsEditModel((Guid)id); if (ad == null) { return(NotFound().WithError(LOCALIZATION_ERROR_NOT_FOUND)); } if (ad.OwnerId != CurrentUserId) { return(RedirectToAction(nameof(Index)).WithError(LOCALIZATION_ERROR_ONLY_OWNER_CAN_EDIT)); } string serializedString = Newtonsoft.Json.JsonConvert.SerializeObject(ad.AdDetail.AdDetailPictures.Select(f => f.File).ToList()); string mainPicture = Newtonsoft.Json.JsonConvert.SerializeObject(ad.MainPictureThumbnail); ViewBag.SerializedPictures = serializedString; ViewBag.MainPictureSerializedString = mainPicture; return(View(ad)); } catch (Exception ex) { _logger.LogError(ex, ex.Message); return(NotFound().WithError(ex.Message)); } }