// GET: /Create
        public ActionResult CreateProvince()
        {
            //Dropdown list for country
            var country = countrycodes.GetAll();

            ViewBag.Country = country.OrderBy(q => q.name);

            var province_view = new province_view();

            return(View(province_view));
        }
        // GET: /Details/5
        public ActionResult ProvinceDetails(string id)
        {
            province_view province_view = provinces_view.GetAll().
                                          Where(c => c.provinceCode == id).FirstOrDefault();

            //var province_view = provinces_view.GetById(id);
            if (province_view == null)
            {
                return(HttpNotFound());
            }
            return(View(province_view));
        }
        public ActionResult EditProvince(province_view province_form_page)
        {
            var _province = provincecodes.GetById(province_form_page.provinceCode);

            _province.code        = province_form_page.provinceCode;
            _province.name        = province_form_page.provinceName;
            _province.countryCode = province_form_page.countryCode;
            _province.lastUpdate  = DateTime.Now;
            provincecodes.Update(_province);
            provincecodes.Commit();

            return(RedirectToAction("Index"));
        }
        public ActionResult CreateProvince(province_view province_form_page)
        {
            var _province = new provincecode();

            _province.code        = province_form_page.provinceCode;
            _province.name        = province_form_page.provinceName;
            _province.countryCode = province_form_page.countryCode;
            _province.createDate  = DateTime.Now;
            _province.lastUpdate  = DateTime.Now;
            provincecodes.Insert(_province);
            provincecodes.Commit();

            return(RedirectToAction("Index"));
        }
        // GET: /Edit/5
        public ActionResult EditProvince(string id)
        {
            //Dropdown list for country
            var country = countrycodes.GetAll();

            ViewBag.Country = country.OrderBy(q => q.name);

            province_view province_view = provinces_view.GetAll().
                                          Where(c => c.provinceCode == id).FirstOrDefault();

            if (province_view == null)
            {
                return(HttpNotFound());
            }
            return(View(province_view));
        }
Beispiel #6
0
        public ActionResult CreateProvince(province_view province_form_page)
        {
            //validation check
            var code1 = provincecodes.GetAll().Where(s => s.code.ToUpper().Contains(province_form_page.provinceCode.ToUpper())).ToList();
            var name1 = provincecodes.GetAll().Where(s => s.name.ToUpper().Contains(province_form_page.provinceName.ToUpper())).ToList();

            var _province = new provincecode();

            _province.code        = province_form_page.provinceCode;
            _province.name        = province_form_page.provinceName;
            _province.countryCode = province_form_page.countryCode;
            _province.createDate  = DateTime.Now;
            _province.lastUpdate  = DateTime.Now;

            //code and name validation

            if (_province.code == null)
            {
                return(RedirectToAction("ErrorMessage"));
            }
            else if (_province.code.Trim().Length > 2)
            {
                return(RedirectToAction("ErrorMessage"));
            }
            else if (code1.Count() > 0)
            {
                return(RedirectToAction("ErrorMessage"));
            }
            else if (_province.name == null)
            {
                return(RedirectToAction("ErrorMessage"));
            }
            else if (_province.name.Trim().Length > 50)
            {
                return(RedirectToAction("ErrorMessage"));
            }
            else if (name1.Count() > 0)
            {
                return(RedirectToAction("ErrorMessage"));
            }

            provincecodes.Insert(_province);
            provincecodes.Commit();

            return(RedirectToAction("Index"));
        }