Пример #1
0
        public async Task <IActionResult> Create(StateRegistrationCreateViewModel model)
        {
            if (ModelState.IsValid)
            {
                var objcategory = new StateRegistration
                {
                    id = model.id
                    ,
                    countryid = model.countryid
                    ,
                    StateName = model.StateName

                    ,
                    isdeleted = false
                    ,
                    isactive = false
                };

                _unitofWork.state.Add(objcategory);
                bool res = _unitofWork.Save();
                TempData["success"] = "Record Save successfully";
                return(RedirectToAction(nameof(Index)));
            }
            else
            {
                ViewBag.Allcountry = _unitofWork.country.GetAll().Where(x => x.isdeleted == false).Select(x => new SelectListItem()
                {
                    Text  = x.countryname,
                    Value = x.id.ToString()
                });
                return(View(model));
            }
        }
Пример #2
0
        public async Task <IActionResult> Edit(StateRegistrationCreateViewModel model)
        {
            if (ModelState.IsValid)
            {
                var storeobj = _unitofWork.state.Get(model.id);
                if (storeobj == null)
                {
                    TempData["error"] = "Record Not Found";
                    return(NotFound());
                }
                storeobj.id        = model.id;
                storeobj.countryid = model.countryid;
                storeobj.StateName = model.StateName;


                _unitofWork.state.Update(storeobj);
                bool res = _unitofWork.Save();
                TempData["success"] = "Record Update successfully";
                return(RedirectToAction(nameof(Index)));
            }
            else
            {
                ViewBag.Allcountry = _unitofWork.country.GetAll().Where(x => x.isdeleted == false).Select(x => new SelectListItem()
                {
                    Text  = x.countryname,
                    Value = x.id.ToString()
                });
                return(View(model));
            }
        }
Пример #3
0
        public IActionResult Create()
        {
            ViewBag.Allcountry = _unitofWork.country.GetAll().Where(x => x.isdeleted == false).Select(x => new SelectListItem()
            {
                Text  = x.countryname,
                Value = x.id.ToString()
            });
            var model = new StateRegistrationCreateViewModel();

            return(View(model));
        }
Пример #4
0
        public IActionResult Edit(int id)
        {
            ViewBag.Allcountry = _unitofWork.country.GetAll().Where(x => x.isdeleted == false).Select(x => new SelectListItem()
            {
                Text  = x.countryname,
                Value = x.id.ToString()
            });
            var objcategory = _unitofWork.state.Get(id);

            if (objcategory == null)
            {
                return(NotFound());
            }
            var model = new StateRegistrationCreateViewModel()
            {
                id        = objcategory.id,
                countryid = objcategory.countryid,
                StateName = objcategory.StateName
            };

            return(View(model));
        }