Пример #1
0
 /// <summary>
 /// ViewModel 转 DataModel
 /// </summary>
 /// <param name="area"></param>
 /// <returns></returns>
 public static AreaInfo AreaVModelToInfo(AreaVModel area)
 {
     if (area == null)
     {
         return(new AreaInfo());
     }
     return(new AreaInfo
     {
         Id = area.Id,
         Name = area.Name,
         Code = area.Code,
         PinYin = area.PinYin,
         SortPinYin = area.SortPinYin,
         Sort = area.Sort,
         ParentCode = area.ParentCode
     });
 }
Пример #2
0
        public JsonResult Add(AreaVModel model)
        {
            var result = new JsonResultModel();

            if (ModelState.IsValid)
            {
                //add
                result.ResultState = Areas.AddArea(Areas.AreaVModelToInfo(model)) > 0;
            }
            else
            {
                result.ResultState = false;
                result.Message     = ModelStateHelper.GetAllErrorMessage(ModelState);
            }

            return(Json(result));
        }
Пример #3
0
        /// <summary>
        /// 设置区域信息
        /// </summary>
        /// <param name="area"></param>
        /// <returns></returns>
        public APIResult SetArea(AreaVModel area)
        {
            APIResult rst = new APIResult();

            try
            {
                rst.Code = 0;
                rst.Msg  = "";
                bll.SetArea(area);
                rst.Data = area.AreaId;
            }
            catch (Exception ex)
            {
                rst.Code = -1;
                rst.Msg  = ex.Message;
                FileLog.WriteLog("设置区域信息错误(SetArea):" + ex.Message + ex.StackTrace);
            }
            return(rst);
        }
Пример #4
0
 public APIResult SetArea(AreaVModel area)
 {
     return(baseInfoHelper.SetArea(area));
 }
Пример #5
0
 public APIResult AddArea(AreaVModel area)
 {
     area.AreaId = 0;
     return(baseInfoHelper.SetArea(area));
 }
Пример #6
0
        public ActionResult Add()
        {
            var vm = new AreaVModel();

            return(View(vm));
        }
Пример #7
0
 /// <summary>
 /// 设置区域信息
 /// </summary>
 /// <param name="area">区域信息</param>
 /// <returns></returns>
 public int SetArea(AreaVModel area)
 {
     return(dal.SetArea(area));
 }