예제 #1
0
        public async Task <ActionResult> Update(FoundByFunction model)
        {
            if (!_permissionService.Authorize(PermissionProvider.ManageDepartment))
            {
                return(AccessDeniedView());
            }
            var foundByFunction = await _foundByFunctionService.GetByIdAsync(model.Id);

            if (foundByFunction == null)
            {
                throw new ArgumentException("No foundByFunction found with the specified id");
            }

            var existedFoundByFunction = await _foundByFunctionService.GetFoundByFunctionByName(model.Name);

            if (existedFoundByFunction != null && existedFoundByFunction.Id != foundByFunction.Id)
            {
                return(Content("FoundByFunction Name has Existed!"));
            }

            foundByFunction.Name = model.Name;
            await _foundByFunctionService.UpdateAsync(foundByFunction);

            return(Json(new
            {
                status = "success",
            }));
        }
예제 #2
0
        public async Task <ActionResult> Create(FoundByFunctionModel foundByFunctionModel)
        {
            if (!_permissionService.Authorize(PermissionProvider.ManageDepartment))
            {
                return(AccessDeniedView());
            }
            var existedFoundByFunction = await _foundByFunctionService.GetFoundByFunctionByName(foundByFunctionModel.Name);

            if (existedFoundByFunction != null)
            {
                return(Content("FoundByFunction Name has Existed!"));
            }

            var foundByFunction = new FoundByFunction()
            {
                Name = foundByFunctionModel.Name
            };
            await _foundByFunctionService.InsertAsync(foundByFunction);

            return(Json(new
            {
                status = "success",
            }));
        }