Exemplo n.º 1
0
        public JsonResult Create(FormCollection postedFormData, [System.Web.Http.FromBody] SysSampleMaintenanceDTO sysSampleDTO)
        {
            TransactionalInformation transaction;

            SysSampleMaintenanceViewModel sysSampleMaintenanceViewModel = new SysSampleMaintenanceViewModel();

            SysSample sysSample = new SysSample();

            ModelStateHelper.UpdateViewModel(sysSampleDTO, sysSample);

            SysSampleApplicationService sysSampleApplicationService = new SysSampleApplicationService(sysSampleDataService);

            sysSampleApplicationService.CreateSysSample(sysSample, out transaction);

            sysSampleMaintenanceViewModel.SysSample        = sysSample;
            sysSampleMaintenanceViewModel.ReturnStatus     = transaction.ReturnStatus;
            sysSampleMaintenanceViewModel.ReturnMessage    = transaction.ReturnMessage;
            sysSampleMaintenanceViewModel.ValidationErrors = transaction.ValidationErrors;


            //LogHandler logHander = new LogHandler(sysLogDataService);

            if (transaction.ReturnStatus == false)
            {
                //var Json = Request.CreateResponse<CustomerMaintenanceViewModel>(HttpStatusCode.BadRequest, customerMaintenanceViewModel);
                //return badresponse;

                //return Json(new
                //{
                //    ReturnStatus = sysSampleMaintenanceViewModel.ReturnStatus,
                //    ViewModel = sysSampleMaintenanceViewModel,
                //    ValidationErrors = sysSampleMaintenanceViewModel.ValidationErrors,
                //    //MessageBoxView = Helpers.MvcHelpers.RenderPartialView(this, "_MessageBox", sysSampleMaintenanceViewModel),
                //    //JsonRequestBehavior.AllowGet
                //});


                LogHandler.WriteServiceLog("虚拟用户", "Id:" + sysSample.Id + ",Name:" + sysSample.Name, "失败", "创建", "样例程序");
                return(Json(JsonHandler.CreateMessage(0, "插入失败" + sysSampleMaintenanceViewModel.ReturnMessage), JsonRequestBehavior.AllowGet));
                //return Json(0, JsonRequestBehavior.AllowGet);
            }
            else
            {
                //var response = Request.CreateResponse<CustomerMaintenanceViewModel>(HttpStatusCode.Created, customerMaintenanceViewModel);
                //return response;

                //return Json(new
                //{
                //    ReturnStatus = sysSampleMaintenanceViewModel.ReturnStatus,
                //    ViewModel = sysSampleMaintenanceViewModel,
                //    ValidationErrors = sysSampleMaintenanceViewModel.ValidationErrors,
                //    //MessageBoxView = Helpers.MvcHelpers.RenderPartialView(this, "_MessageBox", sysSampleMaintenanceViewModel),
                //    JsonRequestBehavior.AllowGet
                //});

                LogHandler.WriteServiceLog("虚拟用户", "Id:" + sysSample.Id + ",Name:" + sysSample.Name, "成功", "创建", "样例程序");
                return(Json(JsonHandler.CreateMessage(1, "插入成功"), JsonRequestBehavior.AllowGet));
                //return Json(1, JsonRequestBehavior.AllowGet);
            }
        }
Exemplo n.º 2
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));
            }
        }
Exemplo n.º 3
0
        public JsonResult Delete(FormCollection postedFormData, [System.Web.Http.FromBody] SysSampleMaintenanceDTO sysSampleDTO)
        {
            TransactionalInformation transaction;

            SysSampleMaintenanceViewModel sysSampleMaintenanceViewModel = new SysSampleMaintenanceViewModel();

            SysSample sysSample = new SysSample();

            ModelStateHelper.UpdateViewModel(sysSampleDTO, sysSample);

            SysSampleApplicationService sysSampleApplicationService = new SysSampleApplicationService(sysSampleDataService);

            sysSampleApplicationService.DeleteSysSampleById(sysSample.Id, out transaction);

            sysSampleMaintenanceViewModel.SysSample        = sysSample;
            sysSampleMaintenanceViewModel.ReturnStatus     = transaction.ReturnStatus;
            sysSampleMaintenanceViewModel.ReturnMessage    = transaction.ReturnMessage;
            sysSampleMaintenanceViewModel.ValidationErrors = transaction.ValidationErrors;


            if (transaction.ReturnStatus == false)
            {
                //var Json = Request.CreateResponse<CustomerMaintenanceViewModel>(HttpStatusCode.BadRequest, customerMaintenanceViewModel);
                //return badresponse;

                //return Json(new
                //{
                //    ReturnStatus = sysSampleMaintenanceViewModel.ReturnStatus,
                //    ViewModel = sysSampleMaintenanceViewModel,
                //    ValidationErrors = sysSampleMaintenanceViewModel.ValidationErrors,
                //    //MessageBoxView = Helpers.MvcHelpers.RenderPartialView(this, "_MessageBox", sysSampleMaintenanceViewModel),
                //    //JsonRequestBehavior.AllowGet
                //});

                return(Json(0, JsonRequestBehavior.AllowGet));
            }
            else
            {
                //var response = Request.CreateResponse<CustomerMaintenanceViewModel>(HttpStatusCode.Created, customerMaintenanceViewModel);
                //return response;

                //return Json(new
                //{
                //    ReturnStatus = sysSampleMaintenanceViewModel.ReturnStatus,
                //    ViewModel = sysSampleMaintenanceViewModel,
                //    ValidationErrors = sysSampleMaintenanceViewModel.ValidationErrors,
                //    //MessageBoxView = Helpers.MvcHelpers.RenderPartialView(this, "_MessageBox", sysSampleMaintenanceViewModel),
                //    JsonRequestBehavior.AllowGet
                //});

                return(Json(1, JsonRequestBehavior.AllowGet));
            }
        }
Exemplo n.º 4
0
        public ActionResult Details(string Id, SysSampleMaintenanceDTO sysSampleDTO)
        {
            TransactionalInformation transaction;

            SysSampleMaintenanceViewModel sysSampleMaintenanceViewModel = new SysSampleMaintenanceViewModel();

            SysSample sysSample = new SysSample();

            ModelStateHelper.UpdateViewModel(sysSampleDTO, sysSample);

            SysSampleApplicationService sysSampleApplicationService = new SysSampleApplicationService(sysSampleDataService);

            sysSample = sysSampleApplicationService.GetSysSampleById(Id, out transaction);

            return(View(sysSample));
        }
Exemplo n.º 5
0
        //[SupportFilter(ActionName = "Create")]
        public JsonResult CreateOpt(FormCollection postedFormData, SysModuleOperateMaintenanceDTO sysModuleOperateDTO)
        {
            TransactionalInformation            transaction;
            SysModuleOperateMaintenancViewModel sysModuleOperateMaintenancViewModel = new SysModuleOperateMaintenancViewModel();


            //if (!ModelState.IsValid)
            //{
            //    var errors = ModelState.errors();
            //sysModuleOperateMaintenancViewModel.ReturnMessage = ModelStateHelper.ReturnErrorMessages(errors);
            //    sysModuleOperateMaintenancViewModel.ValidationErrors = ModelStateHelper.ReturnValidationErrors(errors);
            //    sysModuleOperateMaintenancViewModel.ReturnStatus = false;
            //    var badresponse = Request.CreateResponse<CustomerMaintenanceViewModel>(HttpStatusCode.BadRequest, customerMaintenanceViewModel);
            //    return badresponse;

            //}
            SysModuleOperate sysModuleOperate = new SysModuleOperate();

            ModelStateHelper.UpdateViewModel(sysModuleOperateDTO, sysModuleOperate);

            sysModuleOperate.Id = sysModuleOperate.ModuleId + sysModuleOperate.KeyCode;

            SysModuleOperateApplicationService sysModuleOperateApplicationService = new SysModuleOperateApplicationService(sysModuleOperateDataService);

            sysModuleOperateApplicationService.CreateSysModuleOperate(sysModuleOperate, out transaction);

            sysModuleOperateMaintenancViewModel.SysModuleOperate = sysModuleOperate;
            sysModuleOperateMaintenancViewModel.ReturnStatus     = transaction.ReturnStatus;
            sysModuleOperateMaintenancViewModel.ReturnMessage    = transaction.ReturnMessage;
            sysModuleOperateMaintenancViewModel.ValidationErrors = transaction.ValidationErrors;

            if (transaction.ReturnStatus == false)
            {
                string ErrorCol = errors.Error;
                LogHandler.WriteServiceLog(GetUserId(), "Id" + sysModuleOperate.Id + ",Name" + sysModuleOperate.Name + "," + ErrorCol, "失败", "创建", "SysModule");
                return(Json(JsonHandler.CreateMessage(0, Suggestion.InsertFail + ErrorCol), JsonRequestBehavior.AllowGet));
            }
            else
            {
                LogHandler.WriteServiceLog(GetUserId(), "Id" + sysModuleOperate.Id + ",Name" + sysModuleOperate.Name, "成功", "创建", "SysModule");
                return(Json(JsonHandler.CreateMessage(1, Suggestion.InsertSucceed), JsonRequestBehavior.AllowGet));
            }
        }
        public HttpResponseMessage UpdateCustomer(HttpRequestMessage request, [FromBody] CustomerMaintenanceDTO customerDTO)
        {
            TransactionalInformation transaction;

            CustomerMaintenanceViewModel customerMaintenanceViewModel = new CustomerMaintenanceViewModel();

            if (!ModelState.IsValid)
            {
                var errors = ModelState.Errors();
                customerMaintenanceViewModel.ReturnMessage    = ModelStateHelper.ReturnErrorMessages(errors);
                customerMaintenanceViewModel.ValidationErrors = ModelStateHelper.ReturnValidationErrors(errors);
                customerMaintenanceViewModel.ReturnStatus     = false;
                var badresponse = Request.CreateResponse <CustomerMaintenanceViewModel>(HttpStatusCode.BadRequest, customerMaintenanceViewModel);
                return(badresponse);
            }

            Customer customer = new Customer();

            ModelStateHelper.UpdateViewModel(customerDTO, customer);

            CustomerApplicationService customerApplicationService = new CustomerApplicationService(customerDataService);

            customerApplicationService.UpdateCustomer(customer, out transaction);

            customerMaintenanceViewModel.Customer         = customer;
            customerMaintenanceViewModel.ReturnStatus     = transaction.ReturnStatus;
            customerMaintenanceViewModel.ReturnMessage    = transaction.ReturnMessage;
            customerMaintenanceViewModel.ValidationErrors = transaction.ValidationErrors;

            if (transaction.ReturnStatus == false)
            {
                var badresponse = Request.CreateResponse <CustomerMaintenanceViewModel>(HttpStatusCode.BadRequest, customerMaintenanceViewModel);
                return(badresponse);
            }
            else
            {
                var response = Request.CreateResponse <CustomerMaintenanceViewModel>(HttpStatusCode.Created, customerMaintenanceViewModel);
                return(response);
            }
        }