public IActionResult EditAd(long?adId) { var myUser = GetMyUser(); var model = new EditAdModel(); if (adId.HasValue) { var resultAd = _adsService.GetAd(adId: adId.Value); if (!resultAd.Success) { return(BadRequest()); } if (resultAd.Value.UserId != myUser.Id) { return(BadRequest()); } model = _mapper.Map <EditAdModel>(resultAd.Value); } else { model.DateBorn = DateTime.Today.AddYears(-25); model.HeightCm = 165; model.WeightGr = 55000; } FillBaseModel(model); FillPlaceAdCollections(model); FillPlaceAdPicsIfAny(model); return(View(model)); }
public IActionResult GetAdDetails(long id) { var ad = _adsService.GetAd(adId: id); //if (!ad.Success) // return RedirectToAction(nameof(List)); var adViewModel = _mapper.Map <AdDetailsResponse>(ad.Value); FillPicsUrlsIfAny(adViewModel); FillPicsJson(adViewModel); var resultBox = new AdDetailsBoxResponse(); resultBox.ViewAdModel = adViewModel; return(View(resultBox)); }