/// <summary> /// Tours the package creation. /// </summary> /// <param name="id">The identifier.</param> /// <returns>viewModel</returns> public async Task <IActionResult> Creation(int id) { VendorInformationViewModel model = new VendorInformationViewModel { Id = id }; if (id != 0) { var record = await this.vendorService.GetVendorById(id); model.Name = record.Name; } return(this.View(model)); }
/// <summary> /// Tours the package creation. /// </summary> /// <param name="id">The identifier.</param> /// <returns>viewModel</returns> public async Task <IActionResult> Manage(int id) { VendorInformationViewModel model = new VendorInformationViewModel { Id = id }; if (id > 0) { model = this.Mapper.Map <VendorInformationViewModel>(await this.vendorService.GetVendorById(id)); model.ServiceTypes = await this.vendorService.GetServiceTypesByVendorId(id); } model.CurrencyItems = model.Currency == 0 ? new List <SelectListItem>() : (await this.vendorService.GetCurrencyDropDownListAsync(string.Empty, 1, model.Currency)).ToSelectList(); model.VendorGroupItems = model.Group == 0 || model.Group == null ? new List <SelectListItem>() : (await this.vendorService.GetVendorGroupDropDownListAsync(string.Empty, 1, model.Group)).ToSelectList(); model.CategoryItems = model.Category == 0 ? new List <SelectListItem>() : (await this.vendorService.GetCategoryDropDownListAsync(string.Empty, 1, model.Category)).ToSelectList(); model.CountryItems = model.Country == 0 ? new List <SelectListItem>() : (await this.masterService.GetPackageCountryListAsync(string.Empty, 1, model.Country)).ToSelectList(); model.StateItems = model.State == 0 || model.State == null ? new List <SelectListItem>() : (await this.masterService.GetTourPackageStatesByCountrId(string.Empty, 1, model.Country, (short)model.State)).ToSelectList(); model.CityItems = model.City == 0 ? new List <SelectListItem>() : (await this.masterService.GetTourPackageCityByCounryIdorStateIdAsync(string.Empty, 1, model.Country, model.State == 0 || model.State == null ? (short)0 : (short)model.State, (short)model.City)).ToSelectList(); model.ServiceTypeItems = (await this.vendorService.GetAllVendorServiceTypeItems()).ToSelectList(); return(this.PartialView("ManageVendorInfo", model)); }
public async Task <ActionResult> Manage(VendorInformationViewModel model, string nextview) { if (this.ModelState.IsValid) { int?newId = 0; if (!string.IsNullOrEmpty(nextview)) { this.TempData["nextview"] = nextview; } try { var record = this.Mapper.Map <VendorInformationModel>(model); if (record.Id != 0) { record.UpdateAuditInfo(new Guid(this.HttpContext.User.Claims.FirstOrDefault(x => x.Type == ClaimTypes.Sid).Value)); await this.vendorService.UpdateVendorInfoAsync(record); newId = record.Id; await this.vendorService.DeleteVendorServicesById(Convert.ToInt32(newId)); foreach (var item in model.ServiceTypes) { await this.vendorService.InsertVendorServiceRecord(Convert.ToInt32(newId), item); } this.ShowMessage(Messages.SavedSuccessfully); } else { record.SetAuditInfo(new Guid(this.HttpContext.User.Claims.FirstOrDefault(x => x.Type == ClaimTypes.Sid).Value)); record.IsActive = true; newId = await this.vendorService.AddVendorInfoAsync(record); foreach (var item in model.ServiceTypes) { await this.vendorService.InsertVendorServiceRecord(Convert.ToInt32(newId), item); } this.ShowMessage(Messages.SavedSuccessfully); } } catch (Exception ex) { var str = ex.ToString(); this.ShowMessage(Messages.InsertFailed); return(this.RedirectToRoute(Constants.RouteArea, new { controller = "vendor", action = "index", area = Constants.AreaAdmin })); } if (model.CommandButton != null && model.CommandButton == "SaveandReload") { return(this.RedirectToAction("Creation", "Vendor", new { @area = Constants.AreaAdmin, @id = newId })); } else if (model.CommandButton != null && model.CommandButton == "SubmitAndNext") { this.TempData["nextview"] = "#vendor-contact"; return(this.RedirectToAction("Creation", "Vendor", new { @area = Constants.AreaAdmin, @id = newId })); } else if (model.CommandButton != null && model.CommandButton == "SubmitAndClose") { return(this.RedirectToAction("Index", "Vendor", new { @area = Constants.AreaAdmin })); } else { return(this.RedirectToAction("Index", "Vendor", new { @area = Constants.AreaAdmin })); } } else { this.ShowMessage(Messages.InsertFailed); return(this.RedirectToRoute(Constants.RouteArea, new { controller = "vendor", action = "index", area = Constants.AreaAdmin })); } }