/// <summary> /// Indexes this instance. /// </summary> /// <param name="id">The identifier.</param> /// <returns> /// view /// </returns> public async Task <IActionResult> PopularDestinationAdd(int id) { var model = new PopularDestinationViewModel(); if (id > 0) { PopularDestinationModel data = await this.homeBanner.GetPopularDestinationByIdAsync(id); var result = this.Mapper.Map <PopularDestinationViewModel>(data); result.CountryItems = result.CountryId.HasValue && result.CountryId != 0 ? (await this.masterService.GetPackageCountryListAsync(string.Empty, 1, result.CountryId.Value)).ToSelectList() : new List <Microsoft.AspNetCore.Mvc.Rendering.SelectListItem>(); result.StateItems = result.StateId.HasValue && result.StateId != 0 ? (await this.masterService.GetPackageStateListAsync(string.Empty, 1, result.StateId.Value)).ToSelectList() : new List <Microsoft.AspNetCore.Mvc.Rendering.SelectListItem>(); result.CityItems = result.CityId.HasValue && result.CityId != 0 ? (await this.masterService.GetPackageCityListAsync(string.Empty, 1, result.CityId.Value, 0)).ToSelectList() : new List <Microsoft.AspNetCore.Mvc.Rendering.SelectListItem>(); return(this.View(result)); } return(this.View(model)); }
public async Task <IActionResult> PopularDestinationAdd(PopularDestinationViewModel model) { if (this.ModelState.IsValid) { var data = this.Mapper.Map <PopularDestinationModel>(model); if (model.Id == 0) { var record = this.Mapper.Map <PopularDestinationModel>(model); if (model.ImageFile != null) { record.Image = await this.UploadOnly(model.ImageFile, "BannerImages"); } if (record.CountryId.HasValue) { record.CountryName = (await this.masterService.GetPackageCountryByIdAsync(record.CountryId.Value)).Name; } if (record.StateId.HasValue) { record.StateName = (await this.masterService.GetPackageStateByIdAsync(record.StateId.Value)).Name; } if (record.CityId.HasValue) { record.CityName = (await this.masterService.GetPackageCityByIdAsync(Convert.ToInt16(record.CityId.Value))).Name; } record.SetAuditInfo(new Guid(this.HttpContext.User.Claims.FirstOrDefault(x => x.Type == ClaimTypes.Sid).Value)); await this.homeBanner.InsertPopularDestinationAsync(record); this.ShowMessage(Messages.SavedSuccessfully); } else { if (model.ImageFile != null) { data.Image = await this.UploadOnly(model.ImageFile, "BannerImages"); } if (data.CountryId.HasValue) { data.CountryName = (await this.masterService.GetPackageCountryByIdAsync(data.CountryId.Value)).Name; } if (data.StateId.HasValue) { data.StateName = (await this.masterService.GetPackageStateByIdAsync(data.StateId.Value)).Name; } if (data.CityId.HasValue) { data.CityName = (await this.masterService.GetPackageCityByIdAsync(Convert.ToInt16(data.CityId.Value))).Name; } data.UpdateAuditInfo(new Guid(this.HttpContext.User.Claims.FirstOrDefault(x => x.Type == ClaimTypes.Sid).Value)); await this.homeBanner.UpdatePopularDestinationAsync(data); this.ShowMessage(Messages.UpdateSuccessfully); } return(this.RedirectToAction("PopularDestination", "HomeBanners")); } return(this.View(model)); }