コード例 #1
0
        public static void UpdateModelToViewModel(this Design model, DesignModelDetail vm)
        {
            vm.Id = model.Id;

            vm.Name = model.Name;

            vm.Descreption = model.Descreption;

            if (model.Status)
            {
                vm.Status = "Kích hoạt";
            }
            else
            {
                vm.Status = "Tạm khóa";
            }

            vm.CreateDate = model.CreateDate.Value.ToString("dd/MM/yyyy hh:mm:ss");
            vm.CreateBy   = model.CreateBy;
            if (model.UpdateDate.HasValue)
            {
                vm.UpdateDate = model.UpdateDate.Value.ToString("dd/MM/yyyy hh:mm:ss");
            }
            vm.UpdateBy = model.UpdateBy;
        }
コード例 #2
0
        public JsonResult ViewDetail(int id)
        {
            var model = _designService.GetByKey(id);
            var vm    = new DesignModelDetail();

            model.UpdateModelToViewModel(vm);
            vm.ParentCategory = _categoryService.GetByKey(model.ParentCategoryId).Name;
            return(Json(new
            {
                data = vm
            }));
        }