Пример #1
0
        public ActionResult Add(Epm_Materiel model)
        {
            ResultView <int> view     = new ResultView <int>();
            MaterielView     materiel = new MaterielView();

            #region 表单验证
            if (!model.ProjectId.HasValue || model.ProjectId.Value == 0 || string.IsNullOrWhiteSpace(model.ProjectName))
            {
                view.Flag    = false;
                view.Message = "项目名称不能为空";
                return(Json(view));
            }
            #endregion

            //上传附件
            string fileDataJsonFile = Request.Form["fileDataJsonFile"];//获取上传文件json字符串
            if (!string.IsNullOrWhiteSpace(fileDataJsonFile))
            {
                List <Base_Files> files = JsonConvert.DeserializeObject <List <Base_Files> >(fileDataJsonFile);//将文件信息json字符
                materiel.FileList = files;
            }
            string materielDetails = Request.Form["MaterielDetail"];
            if (!string.IsNullOrWhiteSpace(materielDetails))
            {
                materiel.MaterielDetails = JsonConvert.DeserializeObject <List <Epm_MaterielDetails> >(materielDetails);
            }

            Result <int> result = new Result <int>();
            using (ClientSiteClientProxy proxy = new ClientSiteClientProxy(ProxyEx(Request)))
            {
                materiel.Epm_Materiel = model;
                result = proxy.AddMateriel(materiel);
            }
            return(Json(result.ToResultView()));
        }