コード例 #1
0
 public void MapFrom(Entities.Road_Village e, ref Models.Road_VillageModel m)
 {
     m.Id          = e.Id;
     m.Text        = e.Text;
     m.Description = e.Description;
     m.Type        = e.Type;
     m.WardId      = e.WardId;
     m.RegionId    = e.RegionId;
 }
コード例 #2
0
 public void MapFrom(Models.Road_VillageModel m, ref Entities.Road_Village e)
 {
     e.Id          = m.Id;
     e.Text        = m.Text;
     e.Description = m.Description;
     e.Type        = m.Type;
     e.WardId      = m.WardId;
     e.RegionId    = m.RegionId;
 }
コード例 #3
0
        public ActionResult Update(int id, Models.Road_VillageModel m)
        {
            if (ModelState.IsValid)
            {
                Entities.Road_Village e = new Entities.Road_Village();
                m.MapFrom(m, ref e);
                int result = 0;
                if (id > 0)
                {
                    result = roadService.Update(e);
                }
                else
                {
                    result = roadService.Insert(e);
                }
                if (result <= 0)
                {
                    ViewBag.Message    = AdminConfigs.MESSAGE_UPDATE_ERROR;
                    ViewBag.AlertClass = AdminConfigs.CLASS_ALERT_DANGER;
                    return(PartialView("index", m));
                }
                else
                {
                    ViewBag.AlertClass = AdminConfigs.CLASS_ALERT_SUCCESS;
                    ViewBag.Message    = AdminConfigs.MESSAGE_UPDATE_SUCCESS;
                    ModelState.Clear();

                    //
                    // Xóa đi những thông tin vừa được cập nhật tránh trường hợp click 2 lần.
                    m.Text        = "";
                    m.Description = "";
                }
            }
            else
            {
            }

            PlaceService  placeService  = new PlaceService();
            RegionService regionService = new RegionService();

            m.ListCity     = placeService.ListPlaceItemByParent(0);
            m.ListDistrict = placeService.ListPlaceItemByParent(m.CityId);
            m.ListWard     = placeService.ListPlaceItemByParent(m.DistrictId);
            m.ListRegion   = regionService.List();
            LoadData();
            ViewBag.ListRoad   = roadService.ListItem(m.WardId, m.RegionId);
            ViewBag.ActionForm = "Update";
            return(PartialView("index", m));
        }