Esempio n. 1
0
 /// <summary>
 /// ViewModel 转 DataModel
 /// </summary>
 /// <param name="userbuyinglog"></param>
 /// <returns></returns>
 public static UserBuyingLogInfo UserBuyingLogVModelToInfo(UserBuyingLogVModel userbuyinglog)
 {
     if (userbuyinglog == null)
     {
         return(new UserBuyingLogInfo());
     }
     return(new UserBuyingLogInfo
     {
         Id = userbuyinglog.Id,
         AId = userbuyinglog.AId,
         Score = userbuyinglog.Score,
         UserId = userbuyinglog.UserId,
         CreateTime = userbuyinglog.CreateTime
     });
 }
        public JsonResult Add(UserBuyingLogVModel model)
        {
            var result = new JsonResultModel();

            if (ModelState.IsValid)
            {
                //add
                result.ResultState = UserBuyingLogs.AddUserBuyingLog(UserBuyingLogs.UserBuyingLogVModelToInfo(model)) > 0;
            }
            else
            {
                result.ResultState = false;
                result.Message     = ModelStateHelper.GetAllErrorMessage(ModelState);
            }

            return(Json(result));
        }
        public ActionResult Add()
        {
            var vm = new UserBuyingLogVModel();

            return(View(vm));
        }