コード例 #1
0
        //[SupportFilter(ActionName = "Create")]

        public JsonResult Create(FormCollection postedFormData, SysModuleMaintenanceDTO sysModuleDTO)
        {
            TransactionalInformation      transaction;
            SysModuleMaintenanceViewModel sysModuleMainteranceViewModel = new SysModuleMaintenanceViewModel();
            SysModule sysModule = new SysModule();

            sysModuleDTO.CreatePerson = GetUserId();
            sysModuleDTO.EnglishName  = sysModuleDTO.Name;
            sysModuleDTO.State        = "open";

            ModelStateHelper.UpdateViewModel(sysModuleDTO, sysModule);

            SysModuleApplicationService sysModuleApplicationService = new SysModuleApplicationService(sysModuleDataService);

            sysModuleApplicationService.CreateSysModule(sysModule, out transaction);

            sysModuleMainteranceViewModel.SysModule        = sysModule;
            sysModuleMainteranceViewModel.ReturnStatus     = transaction.ReturnStatus;
            sysModuleMainteranceViewModel.ReturnMessage    = transaction.ReturnMessage;
            sysModuleMainteranceViewModel.ValidationErrors = transaction.ValidationErrors;

            if (transaction.ReturnStatus == false)
            {
                string ErrorCol = errors.Error;
                LogHandler.WriteServiceLog(GetUserId(), "Id" + sysModule.Id + ",Name" + sysModule.Name + "," + ErrorCol, "失败", "创建", "SysModule");
                return(Json(JsonHandler.CreateMessage(0, Suggestion.InsertFail + ErrorCol), JsonRequestBehavior.AllowGet));
            }
            else
            {
                LogHandler.WriteServiceLog(GetUserId(), "Id" + sysModule.Id + ",Name" + sysModule.Name, "成功", "创建", "SysModule");
                return(Json(JsonHandler.CreateMessage(1, Suggestion.InsertSucceed), JsonRequestBehavior.AllowGet));
            }
        }
コード例 #2
0
        public HttpResponseMessage GetSysModuleMaintenanceInformation(string personId, HttpRequestMessage request, string sysModuleID)
        {
            TransactionalInformation sysModuleTransaction;

            SysModuleMaintenanceViewModel sysModuleMaintenanceViewModel = new SysModuleMaintenanceViewModel();

            SysModuleApplicationService sysModuleApplicationService = new SysModuleApplicationService(sysModuleDataService);

            if (sysModuleID != string.Empty)
            {
                SysModule sysModule = sysModuleApplicationService.GetSysModuleBySysModuleID(personId, sysModuleID, out sysModuleTransaction);
                sysModuleMaintenanceViewModel.SysModule     = sysModule;
                sysModuleMaintenanceViewModel.ReturnStatus  = sysModuleTransaction.ReturnStatus;
                sysModuleMaintenanceViewModel.ReturnMessage = sysModuleTransaction.ReturnMessage;
            }

            if (sysModuleMaintenanceViewModel.ReturnStatus == true)
            {
                var response = Request.CreateResponse <SysModuleMaintenanceViewModel>(HttpStatusCode.OK, sysModuleMaintenanceViewModel);
                return(response);
            }

            var badResponse = Request.CreateResponse <SysModuleMaintenanceViewModel>(HttpStatusCode.BadRequest, sysModuleMaintenanceViewModel);

            return(badResponse);
        }