コード例 #1
0
        public async Task <ActionResult> Manage(AddVisaMasterViewModel model)
        {
            try
            {
                var record = this.Mapper.Map <VisaModel>(model);
                if (record.Id != 0)
                {
                    record.UpdateAuditInfo(new Guid(this.HttpContext.User.Claims.FirstOrDefault(x => x.Type == ClaimTypes.Sid).Value));
                    await this.visaServices.UpdateVisaMasterAsync(record);

                    this.ShowMessage(Messages.SavedSuccessfully);
                }
                else
                {
                    record.IsActive = true;
                    record.SetAuditInfo(new Guid(this.HttpContext.User.Claims.FirstOrDefault(x => x.Type == ClaimTypes.Sid).Value));
                    int?newId = await this.visaServices.AddVisaMasterAsync(record);

                    this.ShowMessage(Messages.SavedSuccessfully);
                }

                List <DealVisaModel> dealVisaModels = await this.dealsServices.GetAllVisaFromActiveDealsFromCountryId(model.CountryId);

                if (dealVisaModels != null && dealVisaModels.Count > 0)
                {
                    foreach (var item in dealVisaModels)
                    {
                        item.AdultPrice = model.AdultPrice;
                        ////item.BufferDays = model.BufferDays;
                        item.ChildPrice         = model.ChildPrice;
                        item.DocumentsRequired  = model.DocumentsRequired;
                        item.GeneralPolicy      = model.GeneralPolicy;
                        item.Markup             = model.Markup;
                        item.PhotoSpecification = model.PhotoSpecification;
                        item.ProcessingTime     = model.ProcessingTime;
                        item.VendorId           = model.VendorID;
                        item.UpdateAuditInfo(new Guid(this.HttpContext.User.Claims.FirstOrDefault(x => x.Type == ClaimTypes.Sid).Value));
                        await this.dealsServices.UpdateDealPackageVisa(item);
                    }
                }
            }
            catch (Exception ex)
            {
                var str = ex.ToString();
                this.ShowMessage(Messages.InsertFailed, Enums.MessageType.Error);
                return(this.RedirectToRoute(Constants.RouteArea, new { controller = "Visa", action = "Index", area = Constants.AreaAdmin }));
            }

            return(this.RedirectToRoute(Constants.RouteArea, new { controller = "Visa", action = "Index", area = Constants.AreaAdmin }));
        }
コード例 #2
0
        public async Task <ActionResult> Manage(int id)
        {
            var model = new AddVisaMasterViewModel
            {
                IsActive = true,
                Id       = id
            };

            if (id > 0)
            {
                model              = this.Mapper.Map <AddVisaMasterViewModel>(await this.visaServices.GetVisaMasterByIdAsyn(id));
                model.VendorItems  = model.VendorID == 0 ? new List <SelectListItem>() : (await this.visaServices.GetVendorVisaDropDownListAsync(string.Empty, 0, model.VendorID)).ToSelectList();
                model.CountryItems = model.CountryId == 0 ? new List <SelectListItem>() : (await this.masterService.GetPackageCountryListAsync(string.Empty, 0, model.CountryId, 0)).ToSelectList();
            }

            return(this.View(model));
        }