public Response FindByPK(long id)
        {
            Response response = new Response();

            try
            {
                Processor.Find(id);
                response.Text   = "Account with this PK has been found :" + Environment.NewLine + JsonConverter.JsonConverter.ObjToJson(Processor.Find(id));
                response.Result = true;
            }
            catch (InvalidOperationException)
            {
                response.Text   = $"An account with id: {id} does not exist.";
                response.Result = false;
            }
            return(response);
        }
示例#2
0
        public ApiResponse ListAll()
        {
            AccountProcessor = new AccountProcessor();
            Response         = new ApiResponse();

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

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

                return(Response);
            }
        }
示例#3
0
        public ApiResponse FindByPK(long id)
        {
            AccountProcessor = new AccountProcessor();
            Response         = new ApiResponse();

            try
            {
                AccountProcessor.Find(id);
                Response.text   = "Account with this PK has been found" + Environment.NewLine + JsonConverter.JsonConverter.ObjToJson(AccountProcessor.Find(id));
                Response.result = true;

                return(Response);
            }
            catch (Exception e)
            {
                Response.text   = "An account with this id does not exist" + e;
                Response.result = false;

                return(Response);
            }
        }
示例#4
0
        /// <summary>
        /// Function to find an entity by id .
        /// </summary>
        /// <param name="id">entity id</param>
        /// <returns>response and information about the entity</returns>
        public ApiResponse FindByPk(long id)
        {
            ApiResponse response = new ApiResponse();

            try
            {
                Processor.Find(id);
                response.Text = $"Entity with this primary key < {id} > was found . \n" +
                                $"{Serialization.Serizlize(Processor.Find(id))}";
                response.Result = true;

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

                return(response);
            }
        }