Esempio n. 1
0
        //public AccountService(IAccountProcessor processor)
        //{
        //    this.Processor = processor;
        //}

        /// <summary>
        /// Function to create new a entity .
        /// </summary>
        /// <param name="param">a entity</param>
        /// <returns>response and new entity</returns>
        public ApiResponse Create(AccountParam param)
        {
            ApiResponse response = new ApiResponse();

            try
            {
                response.Text = $"The entity successfully added .\n" +
                                $" {Serialization.Serizlize(Processor.Create(param))}";
                response.Result = true;

                return(response);
            }
            catch (Exception ex)
            {
                response.Result = false;
                response.Text   = ex.Message;

                return(response);
            }
        }
        public void Register(AccountParam param, HttpRequest request)
        {
            string[] credentials = GetHeaderCredentials(request);
            ValidateParameters(credentials[0], param.Email);

            UserParam userParam = new UserParam()
            {
                UserName = credentials[0],
                Password = credentials[1],
                StatusId = 1
            };
            UserResult user = UserProcessor.Create(userParam);

            param.UserId   = user.Id;
            param.StatusId = 1;
            _accountProcessor.Create(param);
        }
Esempio n. 3
0
        public ApiResponse Create(List <AccountParam> param)
        {
            AccountProcessor = new AccountProcessor();
            Response         = new ApiResponse();

            try
            {
                Response.text   = JsonConverter.JsonConverter.ObjToJson(AccountProcessor.Create(param));
                Response.result = true;

                return(Response);
            }
            catch (Exception e)
            {
                Response.text   = "Something went wrong :( " + e;
                Response.result = false;

                return(Response);
            }
        }
        public Response Create(AccountParam param)
        {
            Response response = new Response();

            try
            {
                response.Text   = "This account has been added :" + Environment.NewLine + JsonConverter.JsonConverter.ObjToJson(Processor.Create(param));
                response.Result = true;
            }
            catch (InvalidOperationException)
            {
                response.Text = "The user and/or status you've entered to the account do not exist in the system.";
            }
            catch (Exception)
            {
                response.Text   = "Unfortunately something went wrong. Are you sure that the entity you are trying to create doesn't already exist ?";
                response.Result = false;
            }
            return(response);
        }