Пример #1
0
        private async Task <bool> CheckAndPublish(ManaVote vote)
        {
            if (!vote.Published)
            {
                return(true);
            }

            var created = await RegistrarConnection.CreateBlockchain(vote);

            if (created)
            {
                return(true);
            }

            try
            {
                vote.Published     = false;
                vote.PublishedDate = null;
                await _store.UpdateVote(vote);
            }
            catch (Exception)
            {
                return(false);
            }
            return(false);
        }
        public async Task <IHttpActionResult> Details(int userId)
        {
            try
            {
                var user = await RegistrarConnection.GetRegistrarUser(userId);

                return(Ok(user));
            }
            catch (RegistrarConnectionException e)
            {
                return(BadRequest(e.Message));
            }
        }
        public async Task <IHttpActionResult> Results(string chainString)
        {
            try
            {
                var results = await RegistrarConnection.GetResults(chainString);

                return(Ok(results));
            }
            catch (RegistrarConnectionException e)
            {
                return(BadRequest(e.Message));
            }
        }
        public async Task <IHttpActionResult> ListSettings()
        {
            try
            {
                var settings = await RegistrarConnection.ListRegistrarSettings();

                return(Ok(settings));
            }
            catch (RegistrarConnectionException e)
            {
                return(BadRequest(e.Message));
            }
        }
        public async Task <IHttpActionResult> List()
        {
            try
            {
                var users = await RegistrarConnection.GetRegistrarUsers();

                return(Ok(users));
            }
            catch (RegistrarConnectionException e)
            {
                return(BadRequest(e.Message));
            }
        }
        public async Task <IHttpActionResult> DeleteUser(int id)
        {
            try
            {
                await RegistrarConnection.DeleteUser(id);

                return(Ok());
            }
            catch (RegistrarConnectionException e)
            {
                return(BadRequest(e.Message));
            }
        }
        public async Task <IHttpActionResult> ConfirmEmail(int id)
        {
            try
            {
                await RegistrarConnection.SetEmailConfirmed(id);

                return(Ok());
            }
            catch (RegistrarConnectionException e)
            {
                return(BadRequest(e.Message));
            }
        }
        public async Task <IHttpActionResult> SettingsCustomFieldsPost(IList <CreateCustomUserFieldModel> model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            try
            {
                var fields = await RegistrarConnection.UpdateCustomFields(model);

                return(Ok(fields));
            }
            catch (RegistrarConnectionException e)
            {
                return(BadRequest(e.Message));
            }
        }
        public async Task <IHttpActionResult> SettingsCustomFieldsGet()
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            try
            {
                var fields = await RegistrarConnection.GetCustomFields();

                return(Ok(fields));
            }
            catch (RegistrarConnectionException e)
            {
                return(BadRequest(e.Message));
            }
        }
        public async Task <IHttpActionResult> Register(CreateRegiUser model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            try
            {
                var user = await RegistrarConnection.CreateRegistrarUser(model);

                return(Ok(user));
            }
            catch (RegistrarConnectionException e)
            {
                return(BadRequest(e.Message));
            }
        }
        public async Task <IHttpActionResult> UpdateSetting(UpdateRegiSetting model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            try
            {
                var setting = await RegistrarConnection.UpdateRegistrarSetting(model);

                return(Ok(setting));
            }
            catch (RegistrarConnectionException e)
            {
                return(BadRequest(e.Message));
            }
        }
        public async Task <IHttpActionResult> ChangePassword(ChangePasswordModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            try
            {
                await RegistrarConnection.ChangePassword(model);

                return(Ok());
            }
            catch (RegistrarConnectionException e)
            {
                return(BadRequest(e.Message));
            }
        }