Ejemplo n.º 1
0
        public Region Create(Region region)
        {
            var sqlQuery = "INSERT INTO Region (RegionDescription) VALUES(@RegionDescription); " +
                           "SELECT CAST(SCOPE_IDENTITY() as int)";
            var regionID = _cn.Query<int>(sqlQuery, region).Single();
            region.RegionID = regionID;

            return region;
        }
        public ActionResult CreateRegionPost()
        {
            Region region = new Region();

            region.RegionDescription = Request.Form["regionDescription"];
            _repo.Create(region);

            return RedirectToAction("Index");
        }
Ejemplo n.º 3
0
        public Region Update(Region region)
        {
            var p = new DynamicParameters();
            p.Add("RegionID", region.RegionID);
            p.Add("RegionDescription", region.RegionDescription);

            var sqlQuery = "UPDATE Region " +
                           "SET RegionDescription = @RegionDescription " +
                           "WHERE RegionID = @RegionID";

            _cn.Execute(sqlQuery, p);

            return region;
        }
        public ActionResult EditRegionPost(Region region)
        {
            _repo.Update(region);

            return RedirectToAction("Index");
        }