Beispiel #1
0
        public PatronKind GetManaged()
        {
            var patronKind = PatronKindBusiness.Get(Id);

            if (patronKind == null)
            {
                throw new Exception("Mã loại khách hàng không tồn tại");
            }
            return(patronKind);
        }
Beispiel #2
0
        public void Mutation_UpdatePatron_InvalidPatronKind()
        {
            Database.WriteAsync(realm => realm.Add(new Patron
            {
                Id                 = 11,
                Identification     = "123456789",
                Name               = "Tên khách hàng",
                Email              = "Email khách hàng",
                Gender             = true,
                Birthdate          = DateTimeOffset.Now,
                Nationality        = "Quốc tịch",
                Domicile           = "Nguyên quán",
                Residence          = "Thường trú",
                Company            = "Công ty",
                Note               = "Ghi chú",
                PatronKind         = PatronKindBusiness.Get(1),
                ListOfPhoneNumbers = new List <string> {
                    "12324234"
                }
            })).Wait();

            SchemaHelper.ExecuteAndExpectError(
                "Mã loại khách hàng không tồn tại",
                @"/_GraphQL/Patron/mutation.updatePatron.gql",
                new
            {
                input = new
                {
                    id                 = 11,
                    identification     = "1234243",
                    name               = "Tên khách hàng",
                    email              = "email khách hàng",
                    gender             = true,
                    birthdate          = DateTimeOffset.FromUnixTimeSeconds(857293200),
                    residence          = "Hộ khẩu",
                    domicile           = "Nguyên quán",
                    listOfPhoneNumbers = new[] { "1234", "123445" },
                    nationality        = "Quốc tịch",
                    company            = "BOSCH",
                    note               = "Ghi chú",
                    patronKind         = new
                    {
                        id = 100
                    }
                }
            },
                p => p.PermissionManagePatron = true
                );
        }
Beispiel #3
0
        public PatronKindQuery()
        {
            Field <NonNullGraphType <ListGraphType <NonNullGraphType <PatronKindType> > > >(
                _List,
                "Trả về một danh sách các loại khách hàng có trong hệ thống",
                resolve: _CheckPermission_List(
                    p => p.PermissionGetPatron,
                    context => PatronKindBusiness.Get()
                    )
                );

            Field <NonNullGraphType <PatronKindType> >(
                _Item,
                "Trả về thông tin của một loại khách hàng",
                _IdArgument(),
                _CheckPermission_Object(
                    p => p.PermissionGetPatron,
                    context => PatronKindBusiness.Get(_GetId <int>(context))
                    )
                );
        }
        public PatronKindMutation()
        {
            Field <NonNullGraphType <PatronKindType> >(
                _Creation,
                "Tạo và trả về một loại khách hàng mới",
                _InputArgument <PatronKindCreateInput>(),
                _CheckPermission_TaskObject(
                    p => p.PermissionManagePatronKind,
                    context => PatronKindBusiness.Add(_GetInput(context))
                    )
                );

            Field <NonNullGraphType <PatronKindType> >(
                _Updation,
                "Cập nhật và trả về một loại khách hàng vừa cập nhật",
                _InputArgument <PatronKindUpdateInput>(),
                _CheckPermission_TaskObject(
                    p => p.PermissionManagePatronKind,
                    context => PatronKindBusiness.Update(_GetInput(context))
                    )
                );

            Field <NonNullGraphType <StringGraphType> >(
                _Deletion,
                "Xóa một loại khách hàng",
                _IdArgument(),
                _CheckPermission_String(
                    p => p.PermissionManagePatronKind,
                    context =>
            {
                PatronKindBusiness.Delete(_GetId <int>(context));
                return("Xóa thành công");
            }
                    )
                );
        }