Exemplo n.º 1
0
        public async Task <ActionResult> Manage(int id)
        {
            var model = new PackageCountryViewModel();

            if (id > 0)
            {
                var record = await this.country.GetByIdAsync(id);

                //// model.States = (await this.masterService.GetPackageCountryListAsync(string.Empty, 1, model.CountryId, model.CountryId.ToString())).ToSelectList();
                model             = this.Mapper.Map <PackageCountryViewModel>(record);
                model.RegionList  = (await this.masterService.GetPackageRegionListAsync(string.Empty, 1, record.RegionId)).ToSelectList();
                model.CountryList = (await this.masterService.GetPackageCountryListAsync(string.Empty, 1, record.Id)).ToSelectList();
            }

            return(this.View(model));
        }
Exemplo n.º 2
0
        public async Task <ActionResult> Manage(PackageCountryViewModel model)
        {
            if (this.ModelState.IsValid)
            {
                if (model.Id != 0)
                {
                    if (model.ImageFile != null)
                    {
                        model = await this.UploadOnly("images/Country", model);
                    }

                    var record = this.Mapper.Map <PackageCountryModel>(model);
                    record.SetAuditInfo(0);
                    await this.country.UpdateAsync(record);

                    this.ShowMessage(Messages.SavedSuccessfully);
                }

                return(this.RedirectToRoute(Constants.RouteArea, new { controller = "country", action = "Index", area = Constants.AreaAdmin }));
            }

            return(this.View(model));
        }
Exemplo n.º 3
0
        private async Task <PackageCountryViewModel> UploadOnly(string folder, PackageCountryViewModel model)
        {
            model.Image = await this.UploadImageBlobStorage(folder, model.ImageFile);

            return(model);
        }