Example #1
0
        public async Task <ActionResult> Manage(PackageAreaViewModel model)
        {
            if (this.ModelState.IsValid)
            {
                var record = this.Mapper.Map <PackageAreaModel>(model);
                if (model.Id == 0)
                {
                    await this.areaService.InsertAsync(record);

                    if (!this.IsAjaxRequest())
                    {
                        this.ShowMessage(Messages.SavedSuccessfully);
                    }
                }
                else
                {
                    await this.areaService.UpdateAsync(record);

                    if (!this.IsAjaxRequest())
                    {
                        this.ShowMessage(Messages.UpdateSuccessfully);
                    }
                }

                if (this.IsAjaxRequest())
                {
                    return(this.Json(new { success = true, Name = model.Name, Id = record.Id.ToString() }));
                }

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

            return(this.View(model));
        }
Example #2
0
        public async Task <ActionResult> Manage(int id)
        {
            var model = new PackageAreaViewModel {
                IsActive = true
            };

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

                //// model.States = (await this.masterService.GetPackageCountryListAsync(string.Empty, 1, model.CountryId, model.CountryId.ToString())).ToSelectList();
                model           = this.Mapper.Map <PackageAreaViewModel>(record);
                model.Countries = (await this.masterService.GetPackageCountryListAsync(string.Empty, 1, record.Country)).ToSelectList();
                model.States    = (await this.masterService.GetPackageStateListAsync(string.Empty, 1, record.State)).ToSelectList();
                model.Cities    = (await this.masterService.GetPackageCityListAsync(string.Empty, 1, record.City, 0)).ToSelectList();
            }

            if (this.IsAjaxRequest())
            {
                return(this.View("_area", model));
            }

            return(this.View(model));
        }