Exemplo n.º 1
0
        public async Task <TResponse <bool> > Add(int userId,
                                                  InsertIdentityResourceReq identityResource)
        {
            try
            {
                var canInsert = await CanInsert(identityResource);

                if (canInsert.IsSuccess)
                {
                    var result = await _writeRepository.ExecuteAsync(SqlQuery.IDENTITY_RESOURCE_INSERT, new
                    {
                        identityResource.Name,
                        identityResource.DisplayName,
                        identityResource.Description,
                        identityResource.Enabled,
                        identityResource.NonEditable,
                        identityResource.Required,
                        identityResource.Emphasize,
                        identityResource.ShowInDiscoveryDocument,
                        UserCreated = userId,
                        DateCreated = DateTime.Now,
                        UserUpdated = userId,
                        DateUpdated = DateTime.Now
                    });

                    if (result != null)
                    {
                        if (result.IsSuccess)
                        {
                            if (result.Data == 0)
                            {
                                return(await Fail <bool>($"Insert IDENTITY_RESOURCE {identityResource.Name} is failure"));
                            }

                            return(await Ok(true));
                        }

                        return(await Fail <bool>(result.Message));
                    }

                    return(await Fail <bool>($"Insert IDENTITY_RESOURCE {identityResource.Name} is failure"));
                }

                return(await Fail <bool>(canInsert.Message));
            }
            catch (Exception exception)
            {
                return(await Fail <bool>(exception));
            }
        }
Exemplo n.º 2
0
        public async Task <TResponse <bool> > Add(int userId,
                                                  InsertUserReq user)
        {
            try
            {
                var canInsert = await CanInsert(user);

                if (canInsert.IsSuccess)
                {
                    var result = await _writeRepository.ExecuteAsync(SqlQuery.USER_INSERT, new
                    {
                        user.Username,
                        user.Email,
                        user.Name,
                        user.Phone,
                        Password    = Sha512(user.Password),
                        UserCreated = userId,
                        DateCreated = DateTime.Now,
                        UserUpdated = userId,
                        DateUpdated = DateTime.Now
                    });

                    if (result != null)
                    {
                        if (result.IsSuccess)
                        {
                            if (result.Data == 0)
                            {
                                return(await Fail <bool>($"Insert USER {user.Username} is failure"));
                            }

                            return(await Ok(true));
                        }

                        return(await Fail <bool>(result.Message));
                    }

                    return(await Fail <bool>($"Insert USER {user.Username} is failure"));
                }

                return(await Fail <bool>(canInsert.Message));
            }
            catch (Exception exception)
            {
                return(await Fail <bool>(exception));
            }
        }
Exemplo n.º 3
0
        public async Task <TResponse <bool> > Add(int userId,
                                                  InsertApiEndpointReq apiEndpoint)
        {
            try
            {
                var canInsert = await CanInsert(apiEndpoint);

                if (canInsert.IsSuccess)
                {
                    var result = await _writeRepository.ExecuteAsync(SqlQuery.API_ENDPOINT_INSERT, new
                    {
                        apiEndpoint.Name,
                        apiEndpoint.Controller,
                        apiEndpoint.Action,
                        apiEndpoint.Method,
                        UserCreated = userId,
                        DateCreated = DateTime.Now,
                        UserUpdated = userId,
                        DateUpdated = DateTime.Now
                    });

                    if (result != null)
                    {
                        if (result.IsSuccess)
                        {
                            if (result.Data == 0)
                            {
                                return(await Fail <bool>($"Insert API_ENDPOINT {apiEndpoint.Name} is failure"));
                            }

                            return(await Ok(true));
                        }

                        return(await Fail <bool>(result.Message));
                    }

                    return(await Fail <bool>($"Insert API_ENDPOINT {apiEndpoint.Name} is failure"));
                }

                return(await Fail <bool>(canInsert.Message));
            }
            catch (Exception exception)
            {
                return(await Fail <bool>(exception));
            }
        }
Exemplo n.º 4
0
        public async Task <TResponse <bool> > Add(int userId,
                                                  InsertRoleGroupReq roleGroup)
        {
            try
            {
                var canInsert = await CanInsert(roleGroup);

                if (canInsert.IsSuccess)
                {
                    var result = await _writeRepository.ExecuteAsync(SqlQuery.ROLE_GROUP_INSERT, new
                    {
                        roleGroup.Name,
                        UserCreated = userId,
                        DateCreated = DateTime.Now,
                        UserUpdated = userId,
                        DateUpdated = DateTime.Now
                    });

                    if (result != null)
                    {
                        if (result.IsSuccess)
                        {
                            if (result.Data == 0)
                            {
                                return(await Fail <bool>($"Insert ROLE_GROUP {roleGroup.Name} is failure"));
                            }

                            return(await Ok(true));
                        }

                        return(await Fail <bool>(result.Message));
                    }

                    return(await Fail <bool>($"Insert ROLE_GROUP {roleGroup.Name} is failure"));
                }

                return(await Fail <bool>(canInsert.Message));
            }
            catch (Exception exception)
            {
                return(await Fail <bool>(exception));
            }
        }