Esempio n. 1
0
        public async Task AddFunction()
        {
            var featureId    = _dbFaker.Features.FirstOrDefault()?.Id ?? 0;
            var functionName = "NormalName";

            var functions = await _securityData.AddFunction(functionName, featureId);

            var expected = _dbFaker.Functions.Max(l => l.Id) + 1;

            Assert.AreEqual(ActionStatus.Success, functions.Status);
            Assert.AreEqual(expected, functions.Id);
            _mock.Verify(data => data.AddFunction(functionName, featureId), () => Times.Exactly(1));
        }
        public FunctionVO AddFunction(FunctionVO functionVO)
        {
            if (!ModelState.IsValid)
            {
                functionVO.Message = "請填寫必填欄位";
            }
            else
            {
                var result = _functionService.AddFunction(functionVO);

                if (!string.IsNullOrEmpty(result))
                {
                    functionVO.Message = result;
                }
            }
            return(functionVO);
        }
Esempio n. 3
0
        public ActionResult AddFunction(FunctionVO functionVO)
        {
            if (!ModelState.IsValid)
            {
                Response.StatusCode = (int)HttpStatusCode.BadRequest;
                functionVO.Message  = "請填寫必填欄位";
            }
            else
            {
                var result = _functionService.AddFunction(functionVO);

                if (!string.IsNullOrEmpty(result))
                {
                    CurrentHttpContext.Response.StatusCode = (int)HttpStatusCode.BadRequest;
                    functionVO.Message = result;
                }
                else
                {
                    CurrentHttpContext.Response.StatusCode = (int)HttpStatusCode.OK;
                }
            }
            return(Json(functionVO, JsonRequestBehavior.AllowGet));
        }
        public async Task <IActionResult> AddFunction([FromBody] AddFunctionViewModel viewModel)
        {
            var rs = await _functionService.AddFunction(viewModel);

            if (rs == true)
            {
                return(new OkObjectResult(new
                {
                    statusCode = HttpStatusCode.OK,
                    Message = "Success",
                    data = rs
                }));
            }
            else
            {
                return(new OkObjectResult(new
                {
                    statusCode = HttpStatusCode.BadRequest,
                    Message = "Create Function Faild",
                    data = rs
                }));
            }
        }
Esempio n. 5
0
        public async Task <IActionResult> AddFunction([FromBody] AddFunctionRequest request)
        {
            var result = _securityService.AddFunction(request.FunctionName, request.FeatureId);

            return(Ok(await result));
        }
Esempio n. 6
0
        public FunctionDTO AddFunction(FunctionDTO dto)
        {
            var res = functionService.AddFunction(dto.Name, dto.Content, new PolicyId(dto.PolicyId));

            return(functionMapper.MapToModel(res));
        }