Ejemplo n.º 1
0
        public IHttpActionResult Post(OrganizationPostRequest requestData)
        {
            var response        = new Infrastructure.ViewModel.Base.BaseResponse <Organization>();
            var requestService  = new Service.Utility.RequestDataHelper <OrganizationPostRequest>();
            var checkColumnKeys = new string[3] {
                "name", "orgcode", "token"
            };
            var checkDataEmpty = requestService.CheckColumnEmpty(requestData, checkColumnKeys);

            if (checkDataEmpty == false)
            {
                response.Message = "遺漏參數";
                response.State   = Infrastructure.ViewModel.Base.LogState.RequestDataError;
                response.Success = false;
                return(Content(HttpStatusCode.BadRequest, response));
            }
            var orgService   = new OrganizationService();
            var responseData = orgService.CreateOrganization(requestData);

            if (responseData == null)
            {
                response.Message = "建立失敗";
                response.State   = Infrastructure.ViewModel.Base.LogState.Error;
                response.Success = false;
                return(Ok(response));
            }
            response.Data    = responseData;
            response.Success = true;
            response.Message = "建立成功";
            return(Ok(response));
        }
Ejemplo n.º 2
0
 public ActionResult OrganizationCreate([DataSourceRequest] DataSourceRequest request, OrganizationItem organizationItem)
 {
     if (organizationItem != null && ModelState.IsValid)
     {
         service.CreateOrganization(organizationItem);
     }
     return(Json(new[] { organizationItem }.ToDataSourceResult(request, ModelState)));
 }
Ejemplo n.º 3
0
        public ActionResult Create(OrganizationCreate model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var service = new OrganizationService();

            if (service.CreateOrganization(model))
            {
                TempData["SaveResult"] = "Your organization was created.";
                return(RedirectToAction("Index"));
            }
            ;

            ModelState.AddModelError("", "Organization could not be created");

            return(View(model));
        }
Ejemplo n.º 4
0
        public async Task <IActionResult> CreateOrganization(Organization organization)
        {
            await _organizationService.CreateOrganization(organization);

            return(RedirectToAction(nameof(OrganizationsList)));
        }