public RedirectToRouteResult BasicAdInformationUpdate(AdVM ad) { var config = new MapperConfiguration(cfg => { cfg.CreateMap <AdVM, AdDTO>() .ForMember(dest => dest.DateAdd, opt => opt.Ignore()) .ForMember(dest => dest.CategoryName, opt => opt.Ignore()) .ForMember(dest => dest.Category, opt => opt.Ignore()) .ForMember(dest => dest.Kind, opt => opt.Ignore()) .ForMember(dest => dest.KindName, opt => opt.Ignore()) .ForMember(dest => dest.LocationName, opt => opt.Ignore()) .ForMember(dest => dest.LocationNew, opt => opt.Ignore()) .ForMember(dest => dest.Tags, opt => opt.Ignore()) .ForMember(dest => dest.User, opt => opt.Ignore()) .ForMember(dest => dest.Images, opt => opt.Ignore()) .ForMember(dest => dest.UserId, opt => opt.Ignore()); cfg.CreateMap <TagVM, TagDTO>() .ForMember(t => t.InfoReviewTags, p => p.Ignore()); }); //config.AssertConfigurationIsValid(); var mapper = config.CreateMapper(); var adUpdate = mapper.Map <AdVM, AdDTO>(ad); adService.EditAd(adUpdate); return(RedirectToAction("BasicAdInformation", new { AdId = ad.AdId })); }
public async Task <IActionResult> EditAd(EditAdInputModel model) { if (!this.ModelState.IsValid) { return(this.View(model)); } await adService.EditAd(model.Id, model.Title, model.Description, model.PropertyType, model.Size, model.Location, model.RentPrice, model.BuildingClass); var currentUserProfile = this.User.Identity.Name; var ads = this.adService.GetAgencyAds(currentUserProfile); var minimizedAds = AdToAdViewModel(ads); return(this.View("MyAds", minimizedAds)); }